Skip to content

CloudEvent serializes invalid extension attribute names without validation #300

Description

@jack-burridge-eit

CloudEvent serializes invalid extension attribute names without validation

Repro:

from cloudevents.v1.http import CloudEvent
from cloudevents.v1.conversion import to_structured

event = CloudEvent(
  {
      "type": "example.event",
      "source": "/test",
      "example-extension": "123",
  },
  {"ok": True},
)

_, body = to_structured(event)
print(body)

Expected: construction or serialization rejects example-extension, because CloudEvents attribute names must only contain lowercase ASCII letters and digits.

Actual: the SDK serializes it successfully, producing an invalid CloudEvent. This can fail at runtime with stricter receivers such as Knative Eventing, which rejects the request with 400 Bad Request.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions