Skip to content
This repository was archived by the owner on Aug 6, 2026. It is now read-only.

Commit 0717517

Browse files
authored
fix(cloud-agent): use refreshed token for signed commits (#3652)
1 parent b75b153 commit 0717517

2 files changed

Lines changed: 7 additions & 6 deletions

File tree

packages/agent/src/signed-commit-artefacts.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { readFileSync } from "node:fs";
22
import type { SignedCommitResult } from "@posthog/git/signed-commit";
33
import { PostHogAPIClient } from "./posthog-api";
4-
import { SANDBOX_ENV_FILE } from "./utils/github-token";
4+
5+
const SANDBOX_ENV_FILE = "/tmp/agent-env";
56

67
/**
78
* Best-effort "commit hook": after a successful signed-commit push, record one `commit`

packages/agent/src/utils/github-token.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ import { readFileSync } from "node:fs";
22
import { readGithubTokenFromEnv } from "@posthog/git/signed-commit";
33

44
// helpers for resolving the in-sandbox GitHub token
5-
// agentsh env file (NUL-delimited `key=value` pairs) that the PostHog backend
6-
// rewrites in place when it refreshes the sandbox's GitHub credentials
5+
// Dedicated agentsh credential file (NUL-delimited `key=value` pairs) that the
6+
// PostHog backend rewrites in place when it refreshes GitHub credentials
77
// mid-session. The agent-server process env is frozen at launch, so reading
88
// this live file is how in-process tools pick up a refreshed token without a
99
// process restart.
10-
export const SANDBOX_ENV_FILE = "/tmp/agent-env";
10+
const SANDBOX_GITHUB_ENV_FILE = "/tmp/agent-github-env";
1111

1212
export function readGithubTokenFromSandboxEnvFile(
13-
envFilePath: string = SANDBOX_ENV_FILE,
13+
envFilePath: string = SANDBOX_GITHUB_ENV_FILE,
1414
): string | undefined {
1515
try {
1616
const raw = readFileSync(envFilePath, "utf8");
@@ -36,7 +36,7 @@ export function readGithubTokenFromSandboxEnvFile(
3636
* signed-commit tool — pick up a refreshed token without a restart.
3737
*/
3838
export function resolveGithubToken(
39-
envFilePath: string = SANDBOX_ENV_FILE,
39+
envFilePath: string = SANDBOX_GITHUB_ENV_FILE,
4040
): string | undefined {
4141
return (
4242
readGithubTokenFromSandboxEnvFile(envFilePath) ?? readGithubTokenFromEnv()

0 commit comments

Comments
 (0)