-
Notifications
You must be signed in to change notification settings - Fork 36
fix: Concatenate paths in _get_base_url_with_base_path rather than use urljoin #2448
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
Conversation
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. |
5d98e14 to
77743ac
Compare
…join The current implementation treats the base_path as a relative URL reference and resolves it against the base URL, so it ignores any path segments already set in base_url. We have customers which use a gateway in front of our API and have a setup where the base url contains a path segment
77743ac to
3f362e7
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2448 +/- ##
==========================================
- Coverage 48.85% 48.84% -0.01%
==========================================
Files 191 191
Lines 26149 26152 +3
==========================================
- Hits 12776 12775 -1
- Misses 13373 13377 +4
🚀 New features to boost your workflow:
|
|
/gemini review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request effectively addresses a critical bug where urljoin was incorrectly handling base URLs that already contained path segments. The change to manually concatenate the base URL and base path using f-strings is a robust and correct solution. The addition of a dedicated unit test (test_client_with_base_url_including_path_segments) is highly commendable, ensuring the fix works as expected and preventing future regressions. The code adheres to the repository's style guide, particularly regarding testing and readability.
|
Double-check if you need to also update: Edit: That uses a hardcoded auth-url... hmm... that prob doesn't work for these customers I guess |
|
I'm on the fence about replacing a library function (like from urllib.parse import urlparse, urlunparse
def append_url_path(base_url: str, path: str) -> str:
parsed = urlparse(base_url)
new_path = f"{parsed.path.rstrip('/')}/{path.lstrip('/')}"
return urlunparse(parsed._replace(path=new_path)) |
@gemini-code-assist is this overly cautious? |
|
That's an excellent point, @haakonvt! Your proposed The Your I recommend adopting your |
|
🦄 |
The current implementation treats the base_path as a relative URL reference and resolves it against the base URL, so it ignores any path segments already set in base URL. We have users which use a gateway in front of our API and have a setup where the base url contains a path segment
Description
Please describe the change you have made.
Checklist:
If a new method has been added it should be referenced in cognite.rst in order to generate docs based on its docstring.