Skip to content

service/http: JSON-decode data_base64 when datacontenttype has parameters - #866

Open
eisen0419 wants to merge 1 commit into
dapr:mainfrom
eisen0419:fix/http-topic-datab64-mediatype
Open

eisen0419 wants to merge 1 commit into
dapr:mainfrom
eisen0419:fix/http-topic-datab64-mediatype

Conversation

@eisen0419

Copy link
Copy Markdown

Description

In service/http, topicEventJSON.getData() previously compared in.DataContentType == "application/json" literally when decoding a data_base64 CloudEvent payload. When datacontenttype included media type parameters such as application/json; charset=utf-8, TopicEvent.Data stayed raw []byte instead of matching the decoded JSON value returned for plain application/json and by the gRPC subscriber.

Parse in.DataContentType with mime.ParseMediaType in the data_base64 branch and JSON-unmarshal rawData when the parsed media type is application/json, preserving RawData, the original DataContentType string, and raw []byte fallback for non-JSON, malformed media types, or invalid JSON.

Issue reference

Please reference the issue this PR will close: #855

Fixes #855

Checklist

Please make sure you've completed the relevant tasks for this PR, out of the following list:

  • Code compiles correctly
  • Created/updated tests
  • Extended the documentation

The HTTP subscriber compared the whole datacontenttype string, so a
JSON payload in data_base64 stayed raw bytes when the type included
a parameter such as charset. Parse the media type, as the gRPC
subscriber does, and decode only application/json.

Fixes dapr#855

Signed-off-by: eisen0419 <usetoken0419@gmail.com>
@eisen0419
eisen0419 requested review from a team as code owners November 15, 2026 20:00
@cicoyle cicoyle self-assigned this Nov 20, 2026
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

Successfully merging this pull request may close these issues.

HTTP service: data_base64 payload is not JSON-decoded when datacontenttype has parameters (e.g. application/json; charset=utf-8)

2 participants