fix(runner): wire CP-fetched OIDC token into get_bot_token() for backend API calls#1217
fix(runner): wire CP-fetched OIDC token into get_bot_token() for backend API calls#1217markturansky merged 2 commits intoalphafrom
Conversation
…end API credential calls After fetching from the CP token endpoint, store the token via set_bot_token() in utils.py so that get_bot_token() returns it. This ensures auth.py uses the OIDC token (not an empty string) when fetching per-credential tokens from the backend API, fixing HTTP 401 on credential refresh. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
…hed token Verifies that get_bot_token() returns empty before any CP fetch and returns the OIDC token after a successful fetch — the exact condition that caused HTTP 401 on backend API credential calls when set_bot_token() was missing. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughIntroduces a token caching mechanism where tokens fetched from CP are stored in-process and prioritized during token resolution. The gRPC client calls Changes
Sequence Diagram(s)sequenceDiagram
participant Client as gRPC Client
participant CP as Control Plane
participant Utils as Token Utils
participant Cache as Token Cache
Client->>CP: Fetch token from /token endpoint
CP-->>Client: Return token response
Client->>Utils: Call set_bot_token(token)
Utils->>Cache: Store token in _cp_fetched_token
Client->>Utils: Call get_bot_token()
Utils->>Cache: Check cached CP token
Cache-->>Utils: Return cached token
Utils-->>Client: Return prioritized token
🚥 Pre-merge checks | ✅ 6✅ Passed checks (6 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
✨ Simplify code
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
_fetch_token_from_cp()now callsset_bot_token(token)to store the OIDC token in a module-level cache inutils.pyget_bot_token()checks that cache first, soauth.pycredential fetches to the backend API use the OIDC token instead of an empty stringget_bot_token()is empty before a CP fetch and returns the token after — confirmed to fail without the fixRoot cause
The CP-fetched OIDC token was stored only in
AmbientGRPCClient._token(gRPC channel auth).auth.py'sget_bot_token()had no access to it, so credential token fetches went out unauthenticated → HTTP 401 on every session run.🤖 Generated with Claude Code
Summary by CodeRabbit
Release Notes
New Features
Tests