-
Notifications
You must be signed in to change notification settings - Fork 352
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
Non-default basePath causes issues with URL path escaped subject names #1525
Comments
Hey @pkwarren , thanks for the detailed report and your analysis. I'm wondering what Console version you are running? In the past we already had issues with subjects that require URL encoding, but I'm certain that we resolved these for the schema registry pages. We haven't specifically tested with URL rewriting though. Whenever URL encoding is needed (like the slash) it should be replaced by |
Seeing this with
Yes we are only able to reproduce this with URL rewriting. With the default |
Could you check the network request coming from the frontend and whether the subject is actually requested in an encoded form (i.e. slashes in subjectname encoded)? |
Yes it is - the subject in network inspector is path encoded. I've also reproduced from the command line with curl. |
Thanks for the info. Maybe you are right with the middleware - the URL path may be decoded too early and slashes will be removed there. If you could come up with a PR that would be great |
Update basePathMiddleware to use `RawPath` (if present) over `Path` to ensure that URL path encoded subjects are preserved when routing requests. Update the middleware to also remove the prefix from `RawPath` for consistency. Fixes redpanda-data#1525.
Problem
Loading the schema registry UI or attempting to click 'Produce Record' on a topic integrated with the schema registry fails. The console shows 500 errors, and when looking at network requests there is a 200 request for the schema in the topic but 404 errors attempting to fetch the topic's schema references (if the schema references require URL path escaping - i.e.
%2F
for/
).Steps to reproduce
some-topic-value
) which has one or more references with/
in their names.schemaRegistry
and a non-defaultserver
->basePath
.Suggested Fix
The problem appears to be related to the middleware which is responsible for stripping the
basePath
from incoming requests:console/backend/pkg/api/middlewares.go
Lines 75 to 82 in 8a65264
This section of code needs to use the
r.URL.RawPath
(if present) to build therctx.RoutePath
, not ther.URL.Path
. Here's an example middleware from Chi: https://github.com/go-chi/chi/blob/6ceb498b221efa11f559602beb2463b8b52c2161/middleware/clean_path.go#L18-L22. It should probably also remove the prefix fromRawPath
as well for consistency.I'm happy to raise a PR with the suggested fix.
The text was updated successfully, but these errors were encountered: