Repository navigation
fix(cli): refresh the CAS upload token before it expires - #3473
Conversation
The CAS upload token expires after 30 seconds. The CLI requested it before crafting, so a material that takes longer to craft, such as a big AI coding session under secret redaction, failed to upload with a "JWT expired" error. The CAS connection now gets its token from a provider on each call. The CLI caches the token and requests a new one from the control plane when the cached token is close to expiry. Fixes PFM-7428 Assisted-by: Claude Code Signed-off-by: Jose I. Paris <jiparis@chainloop.dev> Chainloop-Trace-Sessions: a2cde44d-e76c-48c0-8395-818659409bcb
AI Session Checks — 🟢 87% · ✅ 0 failing
|
| Status | Attribution | File | Lines |
|---|---|---|---|
| created | ai | app/cli/pkg/action/cas_token_test.go |
+111 / -0 |
| created | ai | app/cli/pkg/action/cas_token.go |
+73 / -0 |
| modified | ai | pkg/grpcconn/grpcconn_test.go |
+69 / -0 |
| modified | ai | pkg/grpcconn/grpcconn.go |
+28 / -4 |
| modified | ai | app/cli/pkg/action/action.go |
+17 / -1 |
Policies (4)
| Status | Policy | Material | Messages |
|---|---|---|---|
| ✅ Passed | ai-config-ai-agents-allowed |
ai-coding-session-a2cde4 |
- |
| ✅ Passed | ai-config-no-dangerous-commands |
ai-coding-session-a2cde4 |
- |
| ✅ Passed | ai-config-no-secrets |
ai-coding-session-a2cde4 |
- |
| ✅ Passed | ai-config-mcp-servers-allowed |
ai-coding-session-a2cde4 |
- |
PR validation — ✅ 3 passing
| Status | Policy | Material | Messages |
|---|---|---|---|
| ✅ Passed | pr-min-approvals |
pr-info |
- |
| ✅ Passed | pr-description-required |
pr-info |
- |
| ✅ Passed | pr-user-story-linked |
pr-info |
- |
Powered by Chainloop and Chainloop Trace
The CAS upload token expires 30 seconds after the control plane issues it. The CLI requested the token before it crafted a material. When crafting took longer than 30 seconds, the upload failed with a "JWT expired" error. Secret redaction of big AI coding sessions (#3368) is one example: it can take minutes.
This change makes the CLI get the CAS token when each upload starts:
grpcconnhas a newWithTokenProvideroption. The connection asks the provider for the bearer token on each call.The crafter and the CAS client are unchanged.
Fixes PFM-7428
AI disclosure: this change was produced with the assistance of Claude Code.