-
Notifications
You must be signed in to change notification settings - Fork 69
src(receiver): don't default specversion on receiving if there isn't one. #349
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
src(receiver): don't default specversion on receiving if there isn't one. #349
Conversation
* When receiving an event, we should not default the specversion to 1.0 if no specverion field is detected. * If no specversion is detected or the specversion does not conform to a currently supported version, we will now throw a ValidationError This is a BREAKING_CHANGE fixes cloudevents#332, cloudevents#333 Signed-off-by: Lucas Holmquist <[email protected]>
0042df8
to
eef8cec
Compare
Did we need to id also? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lholmquist thinking about this... when we were discussing validation not too long ago, the point was to have loose validation on receipt of a cloud event (since you could be receiving an event from a "faulty" system). But we could give the user to explicitly validate afterwards with the validate()
function. I think probably a misspoke when I said we should throw (sorry!).
The goal would be to create an event without the specversion (or ID) set, and allow for user validation to deal with errors. The only problem is how to do this without changing the existing behavior for users who just want to create an event. Ideally they really shouldn't be required to specify a version - it should just default to 1.0.
let me read that discussion, #328 (comment), and get back to you |
Just want to the workflow straight in my head. A new event/message comes in and is received. The specversion is not something this sdk know about or is missing. No error happens and a new cloudevent is created. The user then calls the CE validate function and receives an error because of the non-valid specversion field, they handle it. I think the only thing we should change is that we don't default the value, since with the loose validation, it is working as intended. And if a user needs to handle the error, I think they can just use the CE.cloneWith method? |
I'm kind of torn on this... Requiring a user to specify the spec version when creating a new event seems a little unfortunate, since it will pretty much always be |
I think we should still default when using the |
@lance i wondering what the next steps are here. This PR is probably not correct the way it is written after reading some of our discussions, i wonder if there really is an issue at all? |
@lholmquist sorry - I have been heads down on an upcoming release and have not had much time to think about this issue. Honestly, I think the way it is now is ok but not great. However, I'm not opposed to just letting this sit and stew for a while. |
Ok, i'm going to close this PR, since it is not the correct way of doing it, if we thought about doing it. Are we still blocked by this for the 4.0 release then? |
I think we are probably good to release next week. |
When receiving an event, we should not default the specversion to 1.0 if no specverion field is detected.
If no specversion is detected or the specversion does not conform to a currently supported version, we will now throw a ValidationError
This is a BREAKING_CHANGE
fixes #332, #333
Signed-off-by: Lucas Holmquist [email protected]