You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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).
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
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).
Beta Was this translation helpful? Give feedback.
All reactions