fix: Unwrap SecretStr tokens when building Trino auth objects - #6771
Open
AdityaPatil22 wants to merge 1 commit into
Open
fix: Unwrap SecretStr tokens when building Trino auth objects#6771AdityaPatil22 wants to merge 1 commit into
AdityaPatil22 wants to merge 1 commit into
Conversation
Signed-off-by: Aditya Patil <adityapatil7649@gmail.com>
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #6771 +/- ##
==========================================
+ Coverage 46.94% 46.97% +0.02%
==========================================
Files 419 419
Lines 51839 51840 +1
Branches 7515 7515
==========================================
+ Hits 24338 24350 +12
+ Misses 25766 25755 -11
Partials 1735 1735
... and 1 file with indirect coverage changes Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does / why we need it:
The Trino offline store fails when using JWT authentication: TypeError: can only concatenate str (not "SecretStr") to str
This happens because AuthConfig.to_trino_auth() passed model.model_dump() directly into Trino's auth classes. For JWT, the token field is a Pydantic SecretStr (to avoid leaking it in logs/reprs), but model_dump() leaves it as a SecretStr object instead of a plain string, and Trino's JWTAuthentication does "Bearer " + self.token internally, which fails on a non-str.
The fix unwraps any SecretStr fields via .get_secret_value() before constructing the Trino auth object, in to_trino_auth(). This is scoped to the auth boundary only — it doesn't touch _get_trino_client(), doesn't monkey-patch the Trino library, and doesn't change the user-facing config format. Other auth types (basic, kerberos, oauth2, certificate) are unaffected since none of their models use SecretStr.
Which issue(s) this PR fixes:
Fixes #6760
Checks
Testing Strategy
Added sdk/python/tests/unit/infra/offline_stores/contrib/trino_offline_store/test_trino_auth.py:
Ran the full trino_offline_store unit test suite (46 passed) plus ruff lint/format on modified files.