cloudevents / cloudevents/sdk-python

CloudEvent serializes invalid extension attribute names without validation

Open Beginner friendly
#300 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
342
Forks
65
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with CloudEvent construction and the conversion.to_structured entry point shown in the repro, then trace where extension attributes are serialized. Re-run the provided example to confirm that names containing characters such as the hyphen are rejected, while valid lowercase-letter and digit names continue to serialize.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.