Should the SchemaValidationHandler still be part of the samples? #4808
Mil (MilKAOS)
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
With this code a sample was provided for implementing schema validation by hooking into the transfer to Azure CosmosDB and evaluating the content of the request against a given schema.
However, this implementation is five years old and does not work well with modern applications for several reasons:
POST Message Handling: The sample code evaluates POST messages, but queries can use POST requests too. You could distinguish them based on Headers.ContentType but most of the time it is set to null. For the queries the value is "application/query+json", but I am not sure if I saw all possible POST variations yet. Using OperationType of RequestMessage would be ideal, but unfortunately it is internal.
Content Parsing: The sample reads the complete content as JSON object. With bulk operations, the content includes serialized header information and maybe multiple JSON objects, making it very difficult to parse and validate.
Due to these issues, the SchemaValidationHandler sample is only useful for basic demo operations and, in my opinion, not for real-world applications.
My question is: Should it even be in the sample set? For me it seems very far from a usable real-world example and is also not easily fixable without a lot of considerations (for example the performance impact of dissecting strings if it has a lot of JSON objects in it).
All reactions