Skip to content

Commit d3ea479

Browse files
claudlosclaude
andcommitted
Block plan-mode tools in Docker with helpful error
Plan/subscription modes (codex-5, gemini-3, *-p variants) rely on host-level OAuth tokens that can't be passed into Docker containers. Instead of silently failing with 401 Unauthorized, detect this early and suggest API-key alternatives or non-Docker mode. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 0549edb commit d3ea479

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

bin/cloding.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -889,6 +889,43 @@ function dockerRun(dockerArgs, models, interactive) {
889889
process.exit(1);
890890
}
891891

892+
// Block plan-mode tools in Docker: subscription auth (OAuth tokens, system
893+
// credential stores) cannot be passed into containers. Suggest alternatives.
894+
if (isPlanProvider) {
895+
const altLines = [];
896+
if (tool === "claude") {
897+
const base = modelArg.replace(/-p$/, "");
898+
altLines.push(
899+
` Use API key mode: cloding docker run -m ${base}-a "..."`,
900+
` Requires: export ANTHROPIC_API_KEY=...`,
901+
` Use OpenRouter: cloding docker run -m ${base} "..."`,
902+
` Requires: export OPENROUTER_API_KEY=...`
903+
);
904+
} else if (tool === "codex") {
905+
altLines.push(
906+
` Use API key mode: cloding docker run -m codex-5-a "..."`,
907+
` Requires: export OPENAI_API_KEY=...`
908+
);
909+
} else if (tool === "gemini") {
910+
altLines.push(
911+
` Use API key mode: cloding docker run -m gemini-3-a "..."`,
912+
` Requires: export GOOGLE_API_KEY=...`
913+
);
914+
}
915+
altLines.push(
916+
` Run without Docker: cloding -m ${modelArg} "..."`
917+
);
918+
console.error(
919+
`Error: Plan/subscription mode (${modelArg}) cannot authenticate inside Docker.\n\n` +
920+
`Subscription auth tokens are stored on your host (system credential\n` +
921+
`store, browser sessions, etc.) and cannot be passed into containers.\n\n` +
922+
`Alternatives:\n` +
923+
altLines.join("\n") +
924+
"\n"
925+
);
926+
process.exit(1);
927+
}
928+
892929
// Validate workspace exists and is a directory
893930
if (!fs.existsSync(workspace)) {
894931
console.error(`Error: Workspace not found: ${workspace}`);

0 commit comments

Comments
 (0)