This repository was archived by the owner on Aug 6, 2026. It is now read-only.
fix(cloud-agent): fall back to legacy env file for github token - #3653
Closed
tatoalo wants to merge 1 commit into
Closed
fix(cloud-agent): fall back to legacy env file for github token#3653tatoalo wants to merge 1 commit into
tatoalo wants to merge 1 commit into
Conversation
During a mixed-version rollout a new agent can run against an older backend that still refreshes GitHub credentials only into the legacy /tmp/agent-env. The reader looked only at the dedicated /tmp/agent-github-env and, when absent, dropped straight to the process env frozen at launch — signing commits with an expired or previous actor's token. Chain a fallback to the legacy live file before the frozen process env, so a refreshed token is used under either backend version. Generated-By: PostHog Code Task-Id: 5d51048c-d903-459e-a770-028ab37f9099
|
Merging to
After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here |
|
React Doctor found no issues in the changed files. 🎉 Reviewed by React Doctor for commit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Follow-up to #3652 (already merged), which pointed the in-sandbox GitHub token reader at the backend's dedicated credential file. A review comment flagged a mixed-version rollout gap: the agent and the backend deploy independently, so a new agent can run against an older backend that still refreshes GitHub credentials only into the legacy
/tmp/agent-env. In that window the reader looked only at/tmp/agent-github-envand, finding it absent, dropped straight to the process env frozen at launch — so a signed commit could use an expired or previous actor's token.Why: keep signed commits using a live, refreshed token across the rollout window regardless of which backend version a sandbox is paired with, avoiding the
Bad credentials (HTTP 401)failure #3652 addressed.Changes
resolveGithubTokennow chains the reads: dedicated/tmp/agent-github-env→ legacy/tmp/agent-env(live-refreshed by older backends) → process env as a last resort. Under the current backend the legacy file excludes the token, so the dedicated file still wins; under an older backend the legacy fallback picks up the fresh token instead of the frozen one.How did you test this?
pnpm --filter @posthog/agent... build(includestsctypecheck) — passespnpm --filter @posthog/agent exec vitest run src/utils/github-token.test.ts— 9 tests pass, including new cases for github-over-legacy precedence and legacy fallbackbiome checkon the changed files — cleanAutomatic notifications
Created with PostHog Code