FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix: Unwrap SecretStr tokens when building Trino auth objects by AdityaPatil22 · Pull Request #6771 · feast-dev/feast · GitHub

fix: Unwrap SecretStr tokens when building Trino auth objects - #6771

Open
AdityaPatil22 wants to merge 2 commits into
feast-dev:masterfrom
AdityaPatil22:fix/trino-offline-store-failures
Open

fix: Unwrap SecretStr tokens when building Trino auth objects#6771
AdityaPatil22 wants to merge 2 commits into
feast-dev:masterfrom
AdityaPatil22:fix/trino-offline-store-failures

Conversation

Copy link
Copy Markdown
Contributor

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

  • I've made sure the tests are passing.
  • My commits are signed off (git commit -s)
  • My PR title follows conventional commits format

Testing Strategy

  • Unit tests

Added sdk/python/tests/unit/infra/offline_stores/contrib/trino_offline_store/test_trino_auth.py:

  • test_jwt_auth_produces_plain_str_token — verifies to_trino_auth() produces a JWTAuthentication whose .token is a plain str equal to the configured token, not a SecretStr.
  • test_oauth2_auth_unchanged — verifies OAuth2 auth is unaffected by the change.

Ran the full trino_offline_store unit test suite (46 passed) plus ruff lint/format on modified files.

AdityaPatil22 requested a review from a team as a code owner August 21, 2026 10:34

codecov-commenter commented Aug 21, 2026
edited
Loading

Copy link
Copy Markdown

⚠️ Please install the to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 47.11%. Comparing base (f0bc070) to head (3e8b255).
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files

@@            Coverage Diff             @@
##           master    #6771      +/-   ##
==========================================
+ Coverage   47.09%   47.11%   +0.02%     
==========================================
  Files         419      419              
  Lines       51878    51879       +1     
  Branches     7525     7525              
==========================================
+ Hits        24430    24441      +11     
+ Misses      25700    25689      -11     
- Partials     1748     1749       +1     
Flag Coverage Δ
go-feature-server 30.58% <ø> (ø)
python-unit 48.42% <100.00%> (+0.02%) ⬆️
Files with missing lines Coverage Δ
...ffline_stores/contrib/trino_offline_store/trino.py 55.40% <100.00%> (+4.72%) ⬆️

Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f0bc070...3e8b255. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

aniketpalu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

It would be valuable to add a test case that verifies the behavior when a config contains both SecretStr and regular fields to ensure the conditional unwrapping works correctly for mixed scenarios.

from feast.infra.offline_stores.contrib.trino_offline_store.trino import AuthConfig


def test_jwt_auth_produces_plain_str_token():

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Not a blocker: While this test ensures OAuth2 auth still works, it could be enhanced to test a config with actual OAuth2 parameters to ensure non-SecretStr fields are handled correctly in the new code path.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Thanks for the suggestion - OAuth2 doesn't actually have any config parameters in CLASSES_BY_AUTH_TYPE (its auth_model is None, and to_trino_auth() short-circuits to trino_auth_cls() with no fields at all), so there's no non-SecretStr field handling to exercise on that path. The new test_to_trino_auth_unwraps_only_secret_fields_in_mixed_model and test_basic_auth_with_plain_fields_unaffected tests cover the non-SecretStr field handling instead.

Copy link
Copy Markdown
Contributor

Please rebase the branch with master.

@ntkathole: Needs ok-to-test

Signed-off-by: Aditya Patil <adityapatil7649@gmail.com>
AdityaPatil22 force-pushed the fix/trino-offline-store-failures branch from 544d067 to 686d242 Compare August 24, 2026 09:01
Signed-off-by: Aditya Patil <adityapatil7649@gmail.com>
AdityaPatil22 force-pushed the fix/trino-offline-store-failures branch from 686d242 to 3e8b255 Compare August 24, 2026 09:05

Copy link
Copy Markdown
Contributor Author

@aniketpalu - Made the changes as suggested, added a test covering the mixed SecretStr + plain field scenario.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The use of JWT in Trino offline store failes

3 participants


Back | FazBrowse Home | New Git URL