Skip to content

Conversation

@Kleinjohann
Copy link

Summary of the changes / Why this is an improvement

Path prefixes in server URLs are now propagated to all requests.
E.g. if the server URL 'http://my-server:1234/crate/' is supplied, requests with SQL queries will be sent to 'http://my-server:1234/crate/_sql?types=true'. Currently, the prefix would be ignored, resulting in 'http://my-server:1234/_sql?types=true' for the same server URL input.
I've encountered multiple setups with proxies that handle forwarding based on path prefixes. This change makes the client work in such setups.

One aspect I'm unsure about:

with patch("crate.client.http.urlparse", side_effect=Exception):
Client("")

Seems like you don't want the client to crash if urllib.parse.urlparse throws an exception, so I wrapped my call in a try-except block:
https://github.com/Kleinjohann/crate-python/blob/d5a7902f44f920646dfe0b19884fc0a635879d19/src/crate/client/http.py#L147-L155
This might however just move unavoidable errors to later stages where they will result in less meaningful error messages. The only hint to anyone trying to debug this would be the warning in the log.
I'm probably missing something here, and it's fine for me to keep it as is, I just somehow didn't feel comfortable implementing it like this.

Fixes #743

@amotl amotl requested a review from mfussenegger January 20, 2026 11:46
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 this pull request may close these issues.

Unable to connect in a proxy setup with path prefix

1 participant