feat(client): Add mint_token() method to Session API#416
Conversation
Semver Impact of This PR🟡 Minor (new features) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨Client
Internal Changes 🔧
Other🤖 This preview updates automatically when you update the PR. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Walrus operator silently drops falsy token values
- Changed the walrus condition to an explicit
is not Nonecheck so empty-string tokens still produce an Authorization header as before.
- Changed the walrus condition to an explicit
Or push these changes by commenting:
@cursor push 529644ee64
Preview (529644ee64)
diff --git a/clients/python/src/objectstore_client/client.py b/clients/python/src/objectstore_client/client.py
--- a/clients/python/src/objectstore_client/client.py
+++ b/clients/python/src/objectstore_client/client.py
@@ -244,7 +244,7 @@
headers.update(
dict(sentry_sdk.get_current_scope().iter_trace_propagation_headers())
)
- if token := self.mint_token():
+ if (token := self.mint_token()) is not None:
headers["Authorization"] = f"Bearer {token}"
return headersThis Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.
| elif isinstance(self._token, str): | ||
| headers["Authorization"] = f"Bearer {self._token}" | ||
| if token := self.mint_token(): | ||
| headers["Authorization"] = f"Bearer {token}" |
There was a problem hiding this comment.
Walrus operator silently drops falsy token values
Low Severity
The refactored _make_headers uses if token := self.mint_token(): which is a truthiness check. If self._token is an empty string "", mint_token() returns "", and the walrus operator evaluates it as falsy, so the Authorization header is silently omitted. The original code unconditionally set the header for any str token. The Rust counterpart (if let Some(token)) doesn't have this asymmetry — it matches any Some value. Using is not None instead of truthiness would preserve the original behavior and stay consistent with Rust.
There was a problem hiding this comment.
this is fine imo



In lieu of pre-signed URLs,
Sessioncan expose a token that can be passed alongside an unsigned URL to temporarily confer access permission.Ref FS-329