-
Notifications
You must be signed in to change notification settings - Fork 16.1k
Fix/utils urls preserve query params #35936
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
base: master
Are you sure you want to change the base?
Fix/utils urls preserve query params #35936
Conversation
- Fix 'compatability' to 'compatibility' in email.py and screenshot_test.py - Fix 'accomodate' to 'accommodate' in email.py and log.py - Fix 'dependant' to 'dependent' in exploreReducer.js - Fix 'begining' to 'beginning' in UPDATING.md - Fix 'occured' to 'occurred' in Header.test.tsx - Fix 'succesful' to 'successful' in test_connection.py
…y_url_query Use parse_qsl(keep_blank_values=True) and urlencode(doseq=True); override keys without dropping duplicates and keep original key order where it can be seen that possible.
Code Review Agent Run #b56472Actionable Suggestions - 0Additional Suggestions - 2
Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
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.
Review by Korbit AI
Korbit automatically attempts to detect when you fix issues in new commits.
| Category | Issue | Status |
|---|---|---|
| Inefficient double iteration over query parameters ▹ view | ||
| Expensive list slice insertion operation ▹ view |
Files scanned
| File Path | Reviewed |
|---|---|
| superset/utils/urls.py | ✅ |
| superset/reports/notifications/email.py | ✅ |
| superset-frontend/src/explore/reducers/exploreReducer.js | ✅ |
| superset/utils/log.py | ✅ |
Explore our documentation to understand the languages and file types we support and the files we ignore.
Check out our docs on how you can make Korbit work best for you and your team.
| idxs = [i for i,(kk,_) in enumerate(pairs) if kk==k] | ||
| if idxs: | ||
| pos = min(idxs) | ||
| pairs = [(kk,vv) for (kk,vv) in pairs if kk!=k] |
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.
Inefficient double iteration over query parameters 
Tell me more
What is the issue?
The code performs two separate iterations over the pairs list - first to find indices, then to filter out matching keys, resulting in O(n²) time complexity when updating multiple parameters.
Why this matters
This approach scales poorly with large query strings or when updating many parameters, as each parameter update requires scanning the entire pairs list twice.
Suggested change ∙ Feature Preview
Use a single pass approach to build the new pairs list while tracking positions, or use a dictionary-based approach for better performance:
result_pairs = []
for i, (kk, vv) in enumerate(pairs):
if kk not in kwargs:
result_pairs.append((kk, vv))
elif kk in kwargs and kk not in processed:
# Insert new values at first occurrence position
v = kwargs[kk]
new = [(kk, str(x)) for x in v] if isinstance(v, (list, tuple)) else [(kk, str(v))]
result_pairs.extend(new)
processed.add(kk)Provide feedback to improve future suggestions
💬 Looking for more details? Reply to this comment to chat with Korbit.
| pos = min(idxs) | ||
| pairs = [(kk,vv) for (kk,vv) in pairs if kk!=k] | ||
| new=[(k,str(x)) for x in v] if isinstance(v, (list,tuple)) else [(k,str(v))] | ||
| pairs[pos:pos]=new |
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.
Expensive list slice insertion operation 
Tell me more
What is the issue?
Using slice assignment to insert elements at a specific position in a list has O(n) time complexity due to the need to shift all subsequent elements.
Why this matters
This operation becomes expensive for large query strings as it requires moving all elements after the insertion point, contributing to the overall poor performance of the function.
Suggested change ∙ Feature Preview
Build the result list incrementally without slice insertions, or use a more efficient data structure like collections.deque for insertions, then convert back to list at the end.
Provide feedback to improve future suggestions
💬 Looking for more details? Reply to this comment to chat with Korbit.
Use parse_qsl(keep_blank_values=True) and urlencode(doseq=True), override keys without dropping duplicates and keep original key order where it can be seen that possible.
Given url: http://x?a=1&a=2&b=&c=3
modify_url_query(url, a=[4,5]) => http://x?a=4&a=5&b=&c=3
modify_url_query(url, d=7) => http://x?a=1&a=2&b=&c=3&d=7
modify_url_query(url, b="") preserves empty value.
ADDITIONAL INFORMATION