-
Notifications
You must be signed in to change notification settings - Fork 16.4k
fix(db): preserve percent encoding in database passwords #36783
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?
Conversation
|
CodeAnt AI is reviewing your PR. Thanks for using CodeAnt! 🎉We're free for open-source projects. if you're enjoying it, help us grow by sharing. Share on X · |
Code Review Agent Run #9cc4c2Actionable Suggestions - 0Additional Suggestions - 1
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 |
Nitpicks 🔍
|
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.
Pull request overview
This PR fixes a critical bug where database connection passwords containing special characters (especially percent signs) fail due to improper URL encoding in the sqlalchemy_uri_decrypted property. The fix ensures passwords survive the encode-store-decode-parse cycle without data loss.
Key Changes:
- Modified
Database.sqlalchemy_uri_decryptedto pre-encode passwords usingurllib.parse.quotebefore setting them on the URL object - Replaced
str(conn)withconn.render_as_string(hide_password=False)to preserve URL encoding - Added comprehensive unit and integration tests for password encoding scenarios
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| superset/models/core.py | Updated sqlalchemy_uri_decrypted property to properly encode special characters in passwords using URL percent-encoding before rendering the URI string |
| tests/unit_tests/models/test_core_database_password_encoding.py | Added comprehensive unit tests covering various special characters, edge cases (empty/None), and different app contexts |
| tests/integration_tests/test_database_password_encoding.py | Added integration tests verifying password encoding through full database model lifecycle including engine creation and password masking |
| @pytest.mark.parametrize( | ||
| "password", | ||
| [ | ||
| "p@ss!word", # noqa: S105 | ||
| "pass#word", # noqa: S105 | ||
| "pass&word", # noqa: S105 | ||
| "pass:word", # noqa: S105 | ||
| "pass/word", # noqa: S105 | ||
| "pass?word", # noqa: S105 | ||
| "pass=word", # noqa: S105 | ||
| "p@ss%w0rd", # noqa: S105 | ||
| "p@ss%25", # noqa: S105 | ||
| ], |
Copilot
AI
Dec 21, 2025
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.
Consider adding test cases for additional edge cases such as passwords containing spaces, backslashes, and unicode characters to ensure comprehensive coverage of the encoding logic. For example: "pass word" (with space), "pass\word" (with backslash), or "pässwörd" (with unicode).
tests/unit_tests/models/test_core_database_password_encoding.py
Outdated
Show resolved
Hide resolved
|
CodeAnt AI finished reviewing your PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #36783 +/- ##
==========================================
+ Coverage 60.48% 68.11% +7.62%
==========================================
Files 1931 640 -1291
Lines 76236 47636 -28600
Branches 8568 5202 -3366
==========================================
- Hits 46114 32445 -13669
+ Misses 28017 13911 -14106
+ Partials 2105 1280 -825
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Code Review Agent Run #caab2eActionable Suggestions - 0Review 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 |
User description
SUMMARY
Fixes a critical bug where database connection passwords containing special characters fail to connect due to improper URL encoding handling in the
sqlalchemy_uri_decryptedproperty.Root Cause:
The
Database.sqlalchemy_uri_decryptedproperty usedstr(conn)to convert SQLAlchemy URL objects to strings, which loses percent encoding during the conversion.Solution:
urllib.parse.quote(safe="")to ensure special characters are properly encodedconn.set(password=encoded_password)conn.render_as_string(hide_password=False)instead ofstr(conn)to preserve the URL encodingThis ensures passwords with special characters survive the encode -> store -> decode -> parse cycle without data loss.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
TESTING INSTRUCTIONS
ADDITIONAL INFORMATION
CodeAnt-AI Description
Preserve percent-encoding for database passwords to avoid connection failures
What Changed
Impact
✅ Fewer database connection failures with special-character passwords✅ Reliable engine creation when passwords contain percent or other special characters✅ Clearer masked connection URLs💡 Usage Guide
Checking Your Pull Request
Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.
Talking to CodeAnt AI
Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:
This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.
Example
Preserve Org Learnings with CodeAnt
You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:
This helps CodeAnt AI learn and adapt to your team's coding style and standards.
Example
Retrigger review
Ask CodeAnt AI to review the PR again, by typing:
Check Your Repository Health
To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.