fix(cloud-agent): use refreshed token for signed commits - #3652
Conversation
Generated-By: PostHog Code Task-Id: 5d51048c-d903-459e-a770-028ab37f9099
|
😎 Merged directly without going through the merge queue, as the queue was empty and the PR was up to date with the target branch - details. |
|
React Doctor found no issues in the changed files. 🎉 Reviewed by React Doctor for commit |
Generated-By: PostHog Code Task-Id: 5d51048c-d903-459e-a770-028ab37f9099
|
| // this live file is how in-process tools pick up a refreshed token without a | ||
| // process restart. | ||
| export const SANDBOX_ENV_FILE = "/tmp/agent-env"; | ||
| const SANDBOX_GITHUB_ENV_FILE = "/tmp/agent-github-env"; |
There was a problem hiding this comment.
Missing Live File Reuses Stale Token
When a sandbox deployment still writes refreshed credentials only to /tmp/agent-env, this new default misses the live file and silently falls back to the process-start token. After credentials rotate or the GitHub actor changes, signed commits can use the expired or previous actor's token instead of the refreshed credential.
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/agent/src/utils/github-token.ts
Line: 10
Comment:
**Missing Live File Reuses Stale Token**
When a sandbox deployment still writes refreshed credentials only to `/tmp/agent-env`, this new default misses the live file and silently falls back to the process-start token. After credentials rotate or the GitHub actor changes, signed commits can use the expired or previous actor's token instead of the refreshed credential.
How can I resolve this? If you propose a fix, please make it concise.
Problem
Why: Long-running cloud agents need signed commits to use credentials refreshed after the agent process starts.
Changes
Read GitHub credentials from the dedicated live credential file while keeping general sandbox metadata resolution unchanged.