Skip to content

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

Closed
@cumason123

Description

@cumason123

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').

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions