-
Notifications
You must be signed in to change notification settings - Fork 584
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clarification of json 'data' section docs disparity #184
Comments
@clemensv you ok if I assign this one to you? |
ping @clemensv |
re-pinging @clemensv |
ping @clemensv |
@rdallman would it help if section 2.1 said that data's value must be valid "stand-alone" JSON? Meaning, that "data" is meant to just be a holder of the real event's data. Then we don't need to say its only a string, binary or map. |
@duglin something along those lines would make sense, yeah. according to the defined grammar, I think it would be of type 'Any', which produces a JSON value (per https://github.com/cloudevents/spec/blob/master/json-format.md#2-attributes). Where JSON could be of type 'String', 'Binary', or 'Any', as defined in the cloud events type mapping specification. At least, that's my interpretation as it follows from 3.1 (discussing a 'json value', or a binary or string that must be inspected if json is the content type). thanks for your reply. |
Goal for for data to hold any compliant JSON, including the example you cite, @rdallman. Section 3.1 spells out the exceptions from 2.3. When contenttype is known to reflect JSON (which in loose interpretation could also be when it's absent), all JSON is allowed in |
@rdallman thoughts? |
That ended up being my intuition, that
this implies a JSON value (eg an array) is not valid (unless it's inside of a string?), as an object is a value but a value is not an object. I'm not 100% sure, but changing this to read:
would make this more clear, if that definition is still correct wrt intentions for non-json things (when json is not specified), in which case it should maybe specify that it can be an Object or if the content type is json, it can be any json value. thank you for following up, I hope this feedback helps clarify the spec :) |
@clemensv thought on the suggested edit? |
"JSON object" should indeed refer to JSON value in order to permit arrays. So, yes, we should change that. |
if "Object" was the source of confusion (it was supposed to imply JSON's any-type: value) then we should be good now. |
@rdallman you agree? Can we close this issue now? |
On today's call we believed that this issue is no longer a concern given the current wording in the spec. Before we close it, @rdallman can you confirm that you're ok with the current text? |
spec.md LGTM now, the type is very clear. thank you! |
Hello. First, thank you for this project, this is a great thing for FaaS at large :)
In implementing the spec, there has been some confusion around 2 particular sections from the docs, I am hoping to have some light shed on which is the 'right' way and then to cement that in the documentation itself. I did not see any open issues or PRs at the moment that resolve this, but may have missed one.
Early in json-format.md section 2.3 https://github.com/cloudevents/spec/blob/master/json-format.md#23-mapping-object-typed-attributes notes (ATOW):
where later on it goes on in 3.1 https://github.com/cloudevents/spec/blob/master/json-format.md#31-special-handling-of-the-data-attribute
The disparity being that in 2.3 the spec seems to define that the "data" section can only contain a json string type (
application/xml
, binary, et al) or a json map type, where in 3.1 the type domain seems to broaden to any json value type (e.g.false
,null
,["list"]
, map, etc.).The main issue here being that, if we implement according to 2.3 this would seem to indicate that sending in
{"contentType":"application/json", "data":["list"]}
would be invalid (as data could only be a map or a string), and we should return an error upon receiving an event with this data section. 3.1 seems much more intuitive (and in implementation, it's quite smooth, for ahem languages without generics ;), however seems in conflict with the type system defined in 2.3. Additionally, it seems wrong to reject events that provide a valid json value in the data section (and 3.1 seems happy with this). Hopefully, this is just a matter of clarifying and this isn't just me being wrong on the internet again.A possible solution: at present, the grammar seems somewhat ambiguous with the
Map
type being rigidly defined as a json map, that could also be an object. In 2.3 the wording is aroundString
,Binary
, orMap
where if 3.1 is the correct way to implement things, this could easily sayString
,Binary
orObject
instead, and since anObject
can have aMap
production this makes complete sense -- as opposed to aMap
which doesn't really have the entireObject
production, asObject
is defined, e.g. aMap
can't have a value offalse
-- even though 2.3 seems to imply aMap
could be anObject
. To put in simpler terms, it seems like we should have things the other way around and say it's aString
,Binary
orObject
whereObject
may be aMap
, vs. the current other way around. Perhaps, I am way off base, too :)Thanks again!
The text was updated successfully, but these errors were encountered: