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

schema_registry_encode double encodes path params #2584

Open
paulius-asvydis opened this issue May 13, 2024 · 1 comment
Open

schema_registry_encode double encodes path params #2584

paulius-asvydis opened this issue May 13, 2024 · 1 comment
Labels
bug processors Any tasks or issues relating specifically to processors

Comments

@paulius-asvydis
Copy link

paulius-asvydis commented May 13, 2024

When using schema_registry_encode processor '/' character is double encoded.

With subject like:

          - schema_registry_encode:
              url: http://my-url
              subject: "main/common"
              refresh_period: 10m

The offending code seems to be:

// internal/impl/confluent/client.go

func (c *schemaRegistryClient) doRequest(ctx context.Context, verb, reqPath string) (resCode int, resBody []byte, err error) {
	reqURL := *c.schemaRegistryBaseURL
	if reqURL.Path, err = url.JoinPath(reqURL.Path, reqPath); err != nil {
		return
	}

       var req *http.Request
       // LOG ADDED FOR DEBUGGING
        fmt.Printf("reqURL: %v\n", reqURL.String())
	if req, err = http.NewRequestWithContext(ctx, verb, reqURL.String(), http.NoBody); err != nil {
		return
	}

// reqURL: http://my-url/subjects/main%252Fcommon/versions/latest

Expected Parsed URL:

http://my-url/subjects/main%2Fcommon/versions/latest

Actual Parsed URL:

http://my-url/subjects/main%252Fcommon/versions/latest

Clearly the '/' character is double encoded.

@mihaitodor mihaitodor added bug processors Any tasks or issues relating specifically to processors labels May 14, 2024
@Mizaro
Copy link

Mizaro commented May 14, 2024

I tried it out and investigated it a bit.
It seems that the problem is in Golang's HTTP library. golang/go#3659
As far as I see, we should implement a workaround to allow any input.

I can start working on a PR to do it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug processors Any tasks or issues relating specifically to processors
Projects
None yet
Development

No branches or pull requests

3 participants