Skip to content

Commit 5eb0624

Browse files
steipetegmays
andcommitted
fix(gateway): clarify URL override auth recovery
Co-authored-by: Gabriel A. Mays <[email protected]>
1 parent c730d8f commit 5eb0624

3 files changed

Lines changed: 13 additions & 4 deletions

File tree

‎src/gateway/call.test.ts‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2246,7 +2246,7 @@ describe("callGateway url override auth requirements", () => {
22462246

22472247
await expect(
22482248
callGateway({ method: "health", url: "wss://override.example/ws" }),
2249-
).rejects.toThrow("explicit credentials");
2249+
).rejects.toThrow(/remove --url to use the configured target/i);
22502250
});
22512251

22522252
it("throws when env URL override is set without env credentials", async () => {
@@ -2258,7 +2258,9 @@ describe("callGateway url override auth requirements", () => {
22582258
},
22592259
});
22602260

2261-
await expect(callGateway({ method: "health" })).rejects.toThrow("explicit credentials");
2261+
await expect(callGateway({ method: "health" })).rejects.toThrow(
2262+
/OPENCLAW_GATEWAY_TOKEN or OPENCLAW_GATEWAY_PASSWORD/i,
2263+
);
22622264
});
22632265
});
22642266

‎src/gateway/call.ts‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,9 +616,16 @@ export function ensureExplicitGatewayAuth(params: {
616616
if (params.urlOverrideSource === "env" && hasResolvedAuth) {
617617
return;
618618
}
619+
const sourceHint =
620+
params.urlOverrideSource === "env"
621+
? "Set OPENCLAW_GATEWAY_TOKEN or OPENCLAW_GATEWAY_PASSWORD alongside OPENCLAW_GATEWAY_URL; config credentials are intentionally not reused."
622+
: params.urlOverrideSource === "cli"
623+
? "For the default local or SSH-tunneled Gateway, remove --url to use the configured target."
624+
: undefined;
619625
const message = [
620626
"gateway url override requires explicit credentials",
621627
params.errorHint,
628+
sourceHint,
622629
params.configPath ? `Config: ${params.configPath}` : undefined,
623630
]
624631
.filter(Boolean)
@@ -1149,7 +1156,7 @@ async function callGatewayWithScopes<T = Record<string, unknown>>(
11491156
urlOverrideSource: context.urlOverrideSource,
11501157
explicitAuth: context.explicitAuth,
11511158
resolvedAuth: resolvedCredentials,
1152-
errorHint: "Fix: pass --token or --password (or gatewayToken in tools).",
1159+
errorHint: "Fix: pass --token or --password with --url (or gatewayToken in tools).",
11531160
configPath: context.configPath,
11541161
});
11551162
ensureRemoteModeUrlConfigured(context);

‎src/tui/gateway-chat.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ describe("resolveGatewayConnection", () => {
141141
loadConfig.mockReturnValue({ gateway: { mode: "local" } });
142142

143143
await expect(resolveGatewayConnection({ url: "wss://override.example/ws" })).rejects.toThrow(
144-
"explicit credentials",
144+
/remove --url to use the configured target/i,
145145
);
146146
});
147147

0 commit comments

Comments
 (0)