惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

H
Help Net Security
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园 - 【当耐特】
Microsoft Azure Blog
Microsoft Azure Blog
Google DeepMind News
Google DeepMind News
Apple Machine Learning Research
Apple Machine Learning Research
有赞技术团队
有赞技术团队
Y
Y Combinator Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
爱范儿
爱范儿
L
LangChain Blog
IT之家
IT之家
酷 壳 – CoolShell
酷 壳 – CoolShell
MongoDB | Blog
MongoDB | Blog
Hugging Face - Blog
Hugging Face - Blog
G
Google Developers Blog
T
Tailwind CSS Blog
Engineering at Meta
Engineering at Meta
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
宝玉的分享
宝玉的分享
博客园 - 三生石上(FineUI控件)
D
DataBreaches.Net
Recent Announcements
Recent Announcements
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix: scope config open path env · openclaw/openclaw@90d2f16
shakkernerd · 2026-06-21 · via Recent Commits to openclaw:main

@@ -2,6 +2,7 @@

22

* Tests for config gateway methods, writes, validation, and auth transitions.

33

*/

44

import { afterEach, describe, expect, it, vi } from "vitest";

5+

import { withEnvAsync } from "../../test-utils/env.js";

56

import {

67

clearConfigSchemaResponseCacheForTests,

78

configHandlers,

@@ -88,70 +89,69 @@ describe("resolveConfigOpenCommand", () => {

8889

});

89909091

describe("config.openFile", () => {

91-

afterEach(() => {

92-

delete process.env.OPENCLAW_CONFIG_PATH;

93-

});

94-9592

it("opens the configured file without shell interpolation", async () => {

96-

process.env.OPENCLAW_CONFIG_PATH = "/tmp/config $(touch pwned).json";

97-

execFileMock.mockImplementation((...args: unknown[]) => {

98-

expect(["open", "xdg-open", "powershell.exe"]).toContain(args[0]);

99-

expect(args[1]).toEqual(["/tmp/config $(touch pwned).json"]);

100-

invokeExecFileCallback(args, null);

101-

return {} as never;

93+

await withEnvAsync({ OPENCLAW_CONFIG_PATH: "/tmp/config $(touch pwned).json" }, async () => {

94+

execFileMock.mockImplementation((...args: unknown[]) => {

95+

expect(["open", "xdg-open", "powershell.exe"]).toContain(args[0]);

96+

expect(args[1]).toEqual(["/tmp/config $(touch pwned).json"]);

97+

invokeExecFileCallback(args, null);

98+

return {} as never;

99+

});

100+101+

const { respond } = await invokeConfigOpenFile();

102+103+

expect(respond).toHaveBeenCalledWith(

104+

true,

105+

{

106+

ok: true,

107+

path: "/tmp/config $(touch pwned).json",

108+

},

109+

undefined,

110+

);

102111

});

103-104-

const { respond } = await invokeConfigOpenFile();

105-106-

expect(respond).toHaveBeenCalledWith(

107-

true,

108-

{

109-

ok: true,

110-

path: "/tmp/config $(touch pwned).json",

111-

},

112-

undefined,

113-

);

114112

});

115113116114

it("returns a detailed error and logs details when the opener fails", async () => {

117-

process.env.OPENCLAW_CONFIG_PATH = "/tmp/config.json";

118-

mockExecFileError(Object.assign(new Error("spawn xdg-open ENOENT"), { code: "ENOENT" }));

119-120-

const { respond, logGateway } = await invokeConfigOpenFile();

121-122-

expect(respond).toHaveBeenCalledWith(

123-

true,

124-

{

125-

ok: false,

126-

path: "/tmp/config.json",

127-

error: "Failed to open config file: spawn xdg-open ENOENT",

128-

},

129-

undefined,

130-

);

131-

expect(logGateway.warn).toHaveBeenCalledWith(

132-

"config.openFile failed path=/tmp/config.json: spawn xdg-open ENOENT",

133-

);

115+

await withEnvAsync({ OPENCLAW_CONFIG_PATH: "/tmp/config.json" }, async () => {

116+

mockExecFileError(Object.assign(new Error("spawn xdg-open ENOENT"), { code: "ENOENT" }));

117+118+

const { respond, logGateway } = await invokeConfigOpenFile();

119+120+

expect(respond).toHaveBeenCalledWith(

121+

true,

122+

{

123+

ok: false,

124+

path: "/tmp/config.json",

125+

error: "Failed to open config file: spawn xdg-open ENOENT",

126+

},

127+

undefined,

128+

);

129+

expect(logGateway.warn).toHaveBeenCalledWith(

130+

"config.openFile failed path=/tmp/config.json: spawn xdg-open ENOENT",

131+

);

132+

});

134133

});

135134136135

it("returns actionable headless environment error when xdg-open reports no method available", async () => {

137-

process.env.OPENCLAW_CONFIG_PATH = "/tmp/config.json";

138-

mockExecFileError(new Error("xdg-open: no method available for opening '/tmp/config.json'"));

139-140-

const { respond, logGateway } = await invokeConfigOpenFile();

141-142-

expect(respond).toHaveBeenCalledWith(

143-

true,

144-

{

145-

ok: false,

146-

path: "/tmp/config.json",

147-

error:

148-

"Cannot open file in headless environment. File path: /tmp/config.json. This environment appears to lack a graphical or terminal browser handler.",

149-

},

150-

undefined,

151-

);

152-

expect(logGateway.warn).toHaveBeenCalledWith(

153-

"config.openFile failed path=/tmp/config.json: xdg-open: no method available for opening '/tmp/config.json'",

154-

);

136+

await withEnvAsync({ OPENCLAW_CONFIG_PATH: "/tmp/config.json" }, async () => {

137+

mockExecFileError(new Error("xdg-open: no method available for opening '/tmp/config.json'"));

138+139+

const { respond, logGateway } = await invokeConfigOpenFile();

140+141+

expect(respond).toHaveBeenCalledWith(

142+

true,

143+

{

144+

ok: false,

145+

path: "/tmp/config.json",

146+

error:

147+

"Cannot open file in headless environment. File path: /tmp/config.json. This environment appears to lack a graphical or terminal browser handler.",

148+

},

149+

undefined,

150+

);

151+

expect(logGateway.warn).toHaveBeenCalledWith(

152+

"config.openFile failed path=/tmp/config.json: xdg-open: no method available for opening '/tmp/config.json'",

153+

);

154+

});

155155

});

156156

});

157157