Skip to content

fix: escape configuration values in UpdateDynamicConfiguration#1505

Open
Demogorgon314 wants to merge 1 commit into
apache:masterfrom
Demogorgon314:fix-escape-configuration-values-in-UpdateDynamicConfiguration
Open

fix: escape configuration values in UpdateDynamicConfiguration#1505
Demogorgon314 wants to merge 1 commit into
apache:masterfrom
Demogorgon314:fix-escape-configuration-values-in-UpdateDynamicConfiguration

Conversation

@Demogorgon314
Copy link
Copy Markdown
Member

Motivation

UpdateDynamicConfiguration build configValue directly into the URL path. If either value contains path-reserved characters such as /, the request path can be interpreted incorrectly.

Modifications

Escape configValue as URL path segments with url.PathEscape, and preserve escaped path values in the REST client request construction. Added tests to verify escaped slashes are kept in the final request path.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to fix incorrect REST request paths when dynamic configuration values contain path-reserved characters (notably /) by path-escaping the value and ensuring the REST client preserves escaped path segments when constructing the outbound request.

Changes:

  • Escape configValue in UpdateDynamicConfigurationWithContext using url.PathEscape.
  • Preserve escaped path segments by setting url.URL.RawPath in the REST client request builder.
  • Add a unit test asserting that an escaped slash (%2F) is preserved in the final request path.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
pulsaradmin/pkg/rest/client.go Preserves escaped URL paths by populating RawPath during request construction.
pulsaradmin/pkg/admin/brokers.go Escapes the dynamic config value when building the update endpoint path.
pulsaradmin/pkg/admin/brokers_test.go Adds a transport-based test to verify escaped slashes remain in the request path.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 64 to +68
Path: endpoint(base.Path, u.Path),
RawPath: endpoint(
base.EscapedPath(),
u.EscapedPath(),
),

func (b *broker) UpdateDynamicConfigurationWithContext(ctx context.Context, configName, configValue string) error {
value := fmt.Sprintf("/configuration/%s/%s", configName, configValue)
value := fmt.Sprintf("/configuration/%s/%s", configName, url.PathEscape(configValue))
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.

2 participants