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

bug: Space character in Subject makes invalid query #113

Open
limoges opened this issue Feb 18, 2025 · 0 comments
Open

bug: Space character in Subject makes invalid query #113

limoges opened this issue Feb 18, 2025 · 0 comments

Comments

@limoges
Copy link

limoges commented Feb 18, 2025

First off, thanks for making this package available.

Now for the "bug".

Turns out that it is possible to have a space character in subject, for example "My little subject" is possible to create in at least Confluent Platform's Kafka schema registry.

When using *SchemaRegistryClient.GetSchemaVersion("My little subject") it will generate an http request like so:

GET /subjects/My+little+subject/versions

Unfortunately, this is not considered correct and schema registry will give us a not found. According to a blog post referred in this StackOverflow post, the package should encode space characters like so:

GET /subjects/My%20little%20subject/versions

This is because the URI standard, seems to expect:

  • For URLs, a space in the path fragment has to be encoded with %20. A space in the query fragment can be encoded with +.

Since the subject is encoded into the URL path, a solution is to use url.PathEscape instead of url.QueryEscape for the cases where were escaping the path.

I'll open a pull-request associated with this issue,

limoges added a commit to limoges/srclient that referenced this issue Feb 18, 2025
Why?
There is a bug detected when, for example, a subject contains space
characters.

The package currently uses `+` to encode space in path instead of `%20`.

There might be other encoding issues I'm not aware of.

What?
I search through code for usage of `httpRequest` and reviewed all calls
to make sure they use url.PathEscape when encoding path parameters.

Some were using url.QueryEscape. Some had no escaping.

Addresses:
riferrei#113
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

No branches or pull requests

1 participant