Repository navigation
fix(json-format): reject data and data_base64 together in JSON schema - #1408
Conversation
The JSON format spec states that the data and data_base64 members are mutually exclusive, but cloudevents.json accepted an event that has both. Add a not/required constraint so validators reject such events, and add schema tests to the tools test suite. Signed-off-by: Raphael Fakhri <153192858+RaphaelFakhri@users.noreply.github.com>
| @@ -0,0 +1,46 @@ | |||
| import json | |||
There was a problem hiding this comment.
Please remove this file - we don't need this kind of test. You can then also remove the changes to requirements.txt
There was a problem hiding this comment.
Done in 4087a01. The test file and the requirements.txt change are removed.
|
One thing we should discuss is whether we want to support one of them being 'null' while the other isn't? To me "null" is the same as absent so I think perhaps this might be more appropriate: |
|
I see the point about "null being absent" - but it's a more active way of expressing that there's no value, which makes me nervous about having both fields present even when one is null. I think it would be okay in terms of the strict interpretation of the spec, but I think it would be confusing to see. (When you see So basically I have a weakly held opinion that it's fine to prevent them both being present, even if one/both of them are null. |
|
ok I can live w/o the null stuff - it's a bit of an edge case anyway. |
Signed-off-by: Raphael Fakhri <153192858+RaphaelFakhri@users.noreply.github.com>
|
thanks. |
Fixes #1407
The JSON format states that the presence of the
dataanddata_base64members is mutually exclusive. The JSON schema incloudevents/formats/cloudevents.jsondoes not enforce this, so a validator accepts an event that has both members.Proposed Changes
not/requiredconstraint tocloudevents.jsonso that an event with bothdataanddata_base64fails validation. Events with only one of them, or neither, still validate.Release Note