Closed
Description
Expected Behavior
When running the following:
from cloudevents.conversion import to_json
from cloudevents.http import CloudEvent as HttpCloudEvent
from cloudevents.pydantic import CloudEvent as PydanticCloudEvent
data = {"data-key": "val"}
attributes = {
"type": "com.example.string",
"source": "https://example.com/event-producer",
"extension-key": "test-value",
}
pydantic_event = PydanticCloudEvent(attributes, data)
http_event = HttpCloudEvent(attributes, data)
print(f'Pydantic Event JSON:\n{to_json(pydantic_event)}\n')
print(f'HTTP Event JSON:\n{to_json(http_event)}\n')
the following should be output:
Pydantic Event JSON:
b'{"specversion": "1.0", "id": "fb848780-bf68-48db-8497-efbedacc495f", "source": "https://example.com/event-producer", "type": "com.example.string", "time": "2023-10-25T13:46:20.207850+00:00", "data": {"data-key": "val"}, "extension-key": "test-value"}}'
HTTP Event JSON:
b'{"specversion": "1.0", "id": "49c6a9a8-c640-428f-ad1a-dce111008cdf", "source": "https://example.com/event-producer", "type": "com.example.string", "time": "2023-10-25T13:46:20.208740+00:00", "data": {"data-key": "val"}, "extension-key": "test-value"}'
Actual Behavior
This is the output:
Pydantic Event JSON:
b'{"specversion": "1.0", "id": "fb848780-bf68-48db-8497-efbedacc495f", "source": "https://example.com/event-producer", "type": "com.example.string", "time": "2023-10-25T13:46:20.207850+00:00", "data": {"data-key": "val"}}'
HTTP Event JSON:
b'{"specversion": "1.0", "id": "49c6a9a8-c640-428f-ad1a-dce111008cdf", "source": "https://example.com/event-producer", "type": "com.example.string", "time": "2023-10-25T13:46:20.208740+00:00", "data": {"data-key": "val"}, "extension-key": "test-value"}'
Note the missing extension-key
value from the Pydantic Event JSON.
Steps to Reproduce the Problem
- Run the above code block
Specifications
- Platform: Mac
- Python Version: 3.11.5
- cloudevents Python SDK version: 1.10.0