Issue: getExtensionApiImportSpecifiers Windows path tests fail on Linux CI
Severity: Low — only affects CI, and only the 2 getExtensionApiImportSpecifiers env-var tests
Affected: test/to-import-specifier-windows.test.mjs — 2 failing subtests
Symptom
CI core-regression job on PR #593 shows:
not ok 3 - converts OPENCLAW_EXTENSION_API_PATH Windows path to file:// URL
not ok 4 - converts OPENCLAW_EXTENSION_API_PATH UNC path to file:// URL
error: 'Expected Windows path as file:// URL: ["C:\\\\Program Files\\\\..."]'
Both tests set process.env.OPENCLAW_EXTENSION_API_PATH to a Windows path, then call getExtensionApiImportSpecifiers() and assert the Windows path appears as a file:// URL.
Root Cause
The production code in index.ts uses process.platform === 'win32' guards:
// index.ts line ~448
if (process.platform === 'win32' && /^[a-zA-Z]:[/\\]/.test(trimmed)) {
return pathToFileURL(trimmed).href;
}
// UNC handling also gated on win32:
if (process.platform === 'win32' && /^\\\\[^\\]+\\[^\\]+/.test(trimmed)) { ... }
The CI runner runs on Linux (/home/runner/work/...), so process.platform === 'win32' is always false. The Windows/UNC paths are returned unchanged instead of being converted, and the assertion fails.
The toImportSpecifier tests already handle this correctly
The sibling toImportSpecifier tests all use:
if (process.platform === "win32") {
it("converts Windows drive-letter backslash path to file:// URL", () => { ... });
it("converts UNC path to file:// URL", () => { ... });
// ...
}
This is why those 15 tests pass. The getExtensionApiImportSpecifiers tests just need the same guard.
Fix
Wrap the 2 failing getExtensionApiImportSpecifiers tests in a process.platform === "win32" block:
// In describe("getExtensionApiImportSpecifiers", () => { ... })
if (process.platform === "win32") {
it("converts OPENCLAW_EXTENSION_API_PATH Windows path to file:// URL (hidden issue #1 fix)", () => {
withEnv("OPENCLAW_EXTENSION_API_PATH", "C:\\Program Files\\openclaw\\dist\\extensionAPI.js", () => {
const specifiers = getExtensionApiImportSpecifiers();
const winSpec = specifiers.find(s => s.includes("Program Files"));
assert.ok(winSpec?.startsWith("file://"), `Expected Windows path as file:// URL: ${JSON.stringify(specifiers)}`);
});
});
it("converts OPENCLAW_EXTENSION_API_PATH UNC path to file:// URL", () => {
withEnv("OPENCLAW_EXTENSION_API_PATH", "\\\\server\\share\\openclaw\\dist\\extensionAPI.js", () => {
const specifiers = getExtensionApiImportSpecifiers();
const uncSpec = specifiers.find(s => s.includes("server") && s.includes("share"));
assert.ok(uncSpec?.startsWith("file://"), `Expected UNC path as file:// URL: ${JSON.stringify(specifiers)}`);
});
});
}
This matches the existing pattern used by the toImportSpecifier tests (lines 53–120 of the same file), which all pass on Linux CI.
Files
- Fix needed:
test/to-import-specifier-windows.test.mjs (lines 179–208)
- Production code:
index.ts (no changes needed — production code is correct)
Note
This is a PR #593 test file bug, not a production code issue. The production toImportSpecifier() and getExtensionApiImportSpecifiers() functions behave correctly — the tests were just missing platform guards.
Issue:
getExtensionApiImportSpecifiersWindows path tests fail on Linux CISeverity: Low — only affects CI, and only the 2
getExtensionApiImportSpecifiersenv-var testsAffected:
test/to-import-specifier-windows.test.mjs— 2 failing subtestsSymptom
CI
core-regressionjob on PR #593 shows:Both tests set
process.env.OPENCLAW_EXTENSION_API_PATHto a Windows path, then callgetExtensionApiImportSpecifiers()and assert the Windows path appears as afile://URL.Root Cause
The production code in
index.tsusesprocess.platform === 'win32'guards:The CI runner runs on Linux (
/home/runner/work/...), soprocess.platform === 'win32'is alwaysfalse. The Windows/UNC paths are returned unchanged instead of being converted, and the assertion fails.The
toImportSpecifiertests already handle this correctlyThe sibling
toImportSpecifiertests all use:This is why those 15 tests pass. The
getExtensionApiImportSpecifierstests just need the same guard.Fix
Wrap the 2 failing
getExtensionApiImportSpecifierstests in aprocess.platform === "win32"block:This matches the existing pattern used by the
toImportSpecifiertests (lines 53–120 of the same file), which all pass on Linux CI.Files
test/to-import-specifier-windows.test.mjs(lines 179–208)index.ts(no changes needed — production code is correct)Note
This is a PR #593 test file bug, not a production code issue. The production
toImportSpecifier()andgetExtensionApiImportSpecifiers()functions behave correctly — the tests were just missing platform guards.