fix: escape configuration values in UpdateDynamicConfiguration#1505
Open
Demogorgon314 wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
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
configValueinUpdateDynamicConfigurationWithContextusingurl.PathEscape. - Preserve escaped path segments by setting
url.URL.RawPathin 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)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
UpdateDynamicConfigurationbuildconfigValuedirectly into the URL path. If either value contains path-reserved characters such as/, the request path can be interpreted incorrectly.Modifications
Escape
configValueas URL path segments withurl.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.