Skip to content

from_http wrong exception raised on binary events with no data #115

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

Closed
cumason123 opened this issue Aug 18, 2020 · 0 comments
Closed

from_http wrong exception raised on binary events with no data #115

cumason123 opened this issue Aug 18, 2020 · 0 comments

Comments

@cumason123
Copy link
Contributor

Expected Behavior

from cloudevents.http import from_http
headers = {"ce-specversion": "1.0", "type": "me.type", "source": "<my-source>"}
from_http(headers, None)

I would expect the above code to raise cloudevents.exceptions.MissingRequiredFields("...")

Actual Behavior

Instead it does raise cloudevents.exceptions.InvalidStructuredJSON("...")

I believe it does this because line 48 we check whether headers is binary and if not we assume this is a structured request and try to read as json.

Perhaps instead of raising InvalidStructuredJSON we should set specversion to None and outside the if statement raise MissingRequiredFields('can't find specversion and couldn't decode json').

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant