Skip to content

Commit 5fae738

Browse files
misc: append workaround clarification for reload configuration errors (#323)
1 parent df18fea commit 5fae738

4 files changed

Lines changed: 32 additions & 2 deletions

File tree

src/CodexAcpClient.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ export class CodexAcpClient {
7272
private pendingAccountUpdated: Promise<AccountUpdatedNotification> | null = null;
7373
private readonly sessionNotificationQueues = new Map<string, Promise<void>>();
7474
private skillExtraRoots: string[] = [];
75+
private configPath: string | null = null;
7576

7677

7778
constructor(codexClient: CodexAppServerClient, codexConfig?: JsonObject, modelProvider?: string) {
@@ -86,7 +87,7 @@ export class CodexAcpClient {
8687
};
8788

8889
async initialize(request: acp.InitializeRequest): Promise<void> {
89-
await this.codexClient.initialize({
90+
const response = await this.codexClient.initialize({
9091
capabilities: {
9192
experimentalApi: true,
9293
requestAttestation: false,
@@ -97,6 +98,11 @@ export class CodexAcpClient {
9798
title: request.clientInfo?.title ?? this.defaultClientInfo.title,
9899
}
99100
});
101+
this.configPath = response?.codexHome ?? null;
102+
}
103+
104+
getHomePath(): string | null {
105+
return this.configPath;
100106
}
101107

102108
async authenticate(authRequest: acp.AuthenticateRequest): Promise<Boolean> {

src/CodexAcpServer.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,10 @@ export class CodexAcpServer {
310310
await this.refreshSessionsAuthState(null);
311311
throw RequestError.internalError(`${(e.message)}\n\nYou have been logged out. Please try again.`);
312312
}
313+
const configPath = this.codexAcpClient.getHomePath() ?? "global";
314+
if (e.message.includes("load config")) {
315+
throw RequestError.internalError(`${e.message}\n\nCheck ${configPath} and project .codex directories, especially their config.toml files, or any CODEX_CONFIG override.`);
316+
}
313317
}
314318

315319
private beginSessionOpen(sessionId: string): number {

src/__tests__/CodexACPAgent/mcp-config-merge.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ url = "https://example.com/mcp"
114114
await expect(codexAcpAgent.newSession({
115115
cwd: "",
116116
mcpServers: [conflictingMcp],
117-
})).rejects.toThrow("url is not supported for stdio");
117+
})).rejects.toMatchObject({
118+
data: expect.stringContaining("url is not supported for stdio"),
119+
});
118120
});
119121
});

src/__tests__/CodexACPAgent/new-session-logout.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,24 @@ describe("New session logout handling", () => {
4141
expect(logoutSpy).toHaveBeenCalledOnce();
4242
});
4343

44+
it("includes the global config path in reload configuration errors", async () => {
45+
const fixture = createCodexMockTestFixture();
46+
const codexAcpAgent = fixture.getCodexAcpAgent();
47+
const codexAcpClient = fixture.getCodexAcpClient();
48+
const codexAppServerClient = fixture.getCodexAppServerClient();
49+
vi.spyOn(codexAcpClient, "authRequired").mockResolvedValue(false);
50+
const logoutSpy = vi.spyOn(codexAcpClient, "logout").mockResolvedValue();
51+
52+
const errorMessage = 'Internal error: "failed to reload config: filesystem path `/tmp` must be absolute, use `~/...`, or start with `:`"';
53+
vi.spyOn(codexAppServerClient, "threadStart").mockRejectedValue(new Error(errorMessage));
54+
55+
expect(logoutSpy).toHaveBeenCalledTimes(0);
56+
await expect(codexAcpAgent.newSession({cwd: "", mcpServers: []}))
57+
.rejects.toMatchObject({
58+
data: expect.stringContaining(`Check global and project .codex directories`),
59+
});
60+
});
61+
4462
it("refreshes OpenAI sessions when newSession error forces logout", async () => {
4563
const fixture = createCodexMockTestFixture();
4664
const codexAcpAgent = fixture.getCodexAcpAgent();

0 commit comments

Comments
 (0)