Skip to content

fix: URL-encode metadata query parameters in dapr publish - #1745

Open
RaphaelFakhri wants to merge 1 commit into
dapr:masterfrom
RaphaelFakhri:fix-publish-metadata-escaping
Open

RaphaelFakhri wants to merge 1 commit into
dapr:masterfrom
RaphaelFakhri:fix-publish-metadata-escaping

Conversation

@RaphaelFakhri

Copy link
Copy Markdown

Description

dapr publish --metadata built the publish query string by concatenating metadata.<key>=<value> pairs without escaping. A value containing &, + or # reached daprd split, altered or truncated. For example, &tier=gold in a cloudevent.source URL became a separate tier parameter, and + in a value became a space.

This change builds the query with url.Values, which encodes keys and values and also sorts the keys, so the generated URL is deterministic. Requests with no metadata are unchanged.

A new unit test, TestGetQueryParamsEncodesSpecialCharacters, decodes the generated query with url.ParseQuery and checks that every value matches the input. The test fails on master and passes with this change.

Issue reference

Please reference the issue this PR will close: #1744

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 (not needed: the flag behavior documented in docs/reference is unchanged)

Metadata keys and values passed with --metadata were concatenated into the
query string without escaping, so values containing &, +, # or spaces
reached daprd split, altered or truncated. Build the query with url.Values.

Signed-off-by: Raphael Fakhri <153192858+RaphaelFakhri@users.noreply.github.com>
@RaphaelFakhri
RaphaelFakhri requested review from a team as code owners November 4, 2026 09:14
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.

dapr publish does not URL-encode --metadata values

1 participant