Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error replacing URI path elements when element names overlap #552

Closed
gdavison opened this issue Nov 12, 2024 · 0 comments · Fixed by #553
Closed

Error replacing URI path elements when element names overlap #552

gdavison opened this issue Nov 12, 2024 · 0 comments · Fixed by #553
Assignees

Comments

@gdavison
Copy link

When replacing URI path elements using the function encoding/httpbinding.replacePathElement, if a later path element's name is a substring of a previous element, e.g. /{namespace}/{name}, it will fail with the following error:

serialization failed: invalid path element, does not contain token stop, /{namespace}/{name}

This does not happen if the substring occurs earlier in the URI, e.g. /{name}/{namespace}.

To reproduce, add the following test cases to TestPathReplace:

{
	Orig:       []byte("/{namespace}/{name}"),
	ExpPath:    []byte("/{namespace}/value"),
	ExpRawPath: []byte("/{namespace}/value"),
	Key:        "name", Val: "value",
},
{
	Orig:       []byte("/{name}/{namespace}"),
	ExpPath:    []byte("/value/{namespace}"),
	ExpRawPath: []byte("/value/{namespace}"),
	Key:        "name", Val: "value",
},

The first case will fail with

expected no error, got invalid path element, does not contain token stop, /{namespace}/{name}

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 a pull request may close this issue.

2 participants