Skip to content

Commit 8bb983c

Browse files
committed
fix(gateway): keep restart probe auth local
1 parent 2a6fab9 commit 8bb983c

3 files changed

Lines changed: 83 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Docs: https://docs.openclaw.ai
1313
### Fixes
1414

1515
- macOS Gateway: detect installed-but-unloaded LaunchAgent split-brain states during status, doctor, and restart, and re-bootstrap launchd supervision before falling back to unmanaged listener restarts. Fixes #67335, #53475, and #71060; refs #58890, #60885, and #70801. Thanks @ze1tgeist88, @dafacto, and @vishutdhar.
16+
- Gateway/restart: keep local restart-health probes on configured local daemon auth without falling back to remote gateway credentials. (#57374, #59439) Thanks @zssggle-rgb and @roytong9.
1617
- Plugins/install: stage bundled plugin runtime dependencies before Gateway startup and drain update restarts while preserving per-plugin isolation when pre-stage scan or install fails. Thanks @codex.
1718
- CLI/startup: read generated startup metadata from the bundled `dist` layout before falling back to live help rendering, so root/browser help and channel-option bootstrap stay on the fast path. Thanks @vincentkoc.
1819
- CLI/help: treat positional `help` invocations like `openclaw channels help` as help paths for startup gating, avoiding model/auth warmup while preserving positional arguments such as `openclaw docs help`. Thanks @gumadeiras.

src/gateway/probe-auth.test.ts

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,30 @@ describe("resolveGatewayProbeAuthSafe", () => {
7777
} as OpenClawConfig);
7878
});
7979

80+
it("does not fall through to remote credentials for local probes", () => {
81+
const result = resolveGatewayProbeAuthSafe({
82+
cfg: {
83+
gateway: {
84+
mode: "local",
85+
remote: {
86+
url: "wss://gateway.example",
87+
token: "remote-token",
88+
password: "remote-password", // pragma: allowlist secret
89+
},
90+
},
91+
} as OpenClawConfig,
92+
mode: "local",
93+
env: {} as NodeJS.ProcessEnv,
94+
});
95+
96+
expect(result).toEqual({
97+
auth: {
98+
token: undefined,
99+
password: undefined,
100+
},
101+
});
102+
});
103+
80104
it("ignores unresolved local token SecretRef in remote mode when remote-only auth is requested", () => {
81105
const result = resolveGatewayProbeAuthSafe({
82106
cfg: {
@@ -171,6 +195,36 @@ describe("resolveGatewayProbeAuthSafeWithSecretInputs", () => {
171195
});
172196
});
173197

198+
it("does not resolve remote SecretRefs for local probes", async () => {
199+
const result = await resolveGatewayProbeAuthSafeWithSecretInputs({
200+
cfg: {
201+
gateway: {
202+
mode: "local",
203+
remote: {
204+
url: "wss://gateway.example",
205+
token: { source: "env", provider: "default", id: "REMOTE_GATEWAY_TOKEN" },
206+
},
207+
},
208+
secrets: {
209+
providers: {
210+
default: { source: "env" },
211+
},
212+
},
213+
} as OpenClawConfig,
214+
mode: "local",
215+
env: {
216+
REMOTE_GATEWAY_TOKEN: "remote-token",
217+
} as NodeJS.ProcessEnv,
218+
});
219+
220+
expect(result).toEqual({
221+
auth: {
222+
token: undefined,
223+
password: undefined,
224+
},
225+
});
226+
});
227+
174228
it("returns warning and empty auth when SecretRef cannot be resolved via async path", async () => {
175229
const result = await resolveGatewayProbeAuthSafeWithSecretInputs({
176230
cfg: {

src/gateway/probe-auth.ts

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ function buildGatewayProbeCredentialPolicy(params: {
1515
env?: NodeJS.ProcessEnv;
1616
explicitAuth?: ExplicitGatewayAuth;
1717
}) {
18+
const cfg = resolveGatewayProbeCredentialConfig(params);
1819
return {
19-
config: params.cfg,
20-
cfg: params.cfg,
20+
config: cfg,
21+
cfg,
2122
env: params.env,
2223
explicitAuth: params.explicitAuth,
2324
modeOverride: params.mode,
@@ -26,6 +27,31 @@ function buildGatewayProbeCredentialPolicy(params: {
2627
};
2728
}
2829

30+
function resolveGatewayProbeCredentialConfig(params: {
31+
cfg: OpenClawConfig;
32+
mode: "local" | "remote";
33+
}): OpenClawConfig {
34+
if (params.mode !== "local") {
35+
return params.cfg;
36+
}
37+
38+
const remote = params.cfg.gateway?.remote;
39+
if (!remote || (remote.token === undefined && remote.password === undefined)) {
40+
return params.cfg;
41+
}
42+
43+
const remoteWithoutAuth = { ...remote };
44+
delete remoteWithoutAuth.token;
45+
delete remoteWithoutAuth.password;
46+
return {
47+
...params.cfg,
48+
gateway: {
49+
...params.cfg.gateway,
50+
remote: remoteWithoutAuth,
51+
},
52+
};
53+
}
54+
2955
function resolveExplicitProbeAuth(explicitAuth?: ExplicitGatewayAuth): {
3056
token?: string;
3157
password?: string;

0 commit comments

Comments
 (0)