Skip to content

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

Open
AdityaPatil22 wants to merge 1 commit 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 1 commit into
feast-dev:masterfrom
AdityaPatil22:fix/trino-offline-store-failures

Conversation

@AdityaPatil22

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.

Signed-off-by: Aditya Patil <adityapatil7649@gmail.com>
@AdityaPatil22
AdityaPatil22 requested a review from a team as a code owner August 21, 2026 10:34
@codecov-commenter

codecov-commenter commented Aug 21, 2026

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 46.97%. Comparing base (03dac6f) to head (544d067).
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files

Impacted file tree graph

@@            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              
Flag Coverage Δ
go-feature-server 30.58% <ø> (ø)
python-unit 48.27% <100.00%> (+0.02%) ⬆️
Files with missing lines Coverage Δ
...ffline_stores/contrib/trino_offline_store/trino.py 55.40% <100.00%> (+4.72%) ⬆️

... and 1 file with indirect coverage changes


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 03dac6f...544d067. 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.

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

2 participants