You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maka.apache.org by "sunrioa (via GitHub)" <gi...@apache.org> on 2026/09/04 09:32:18 UTC
[I] fix(eval): decode file URLs before launching test wrappers [maka]
sunrioa opened a new issue, #4757:
URL: https://github.com/apache/maka/issues/4757
## Problem
Some Eval tests fail when the repository checkout path contains spaces or other characters that require URL encoding.
The affected tests construct wrapper locations with `new URL(..., import.meta.url).pathname` and pass the resulting value directly to `child_process`:
- `packages/eval/src/__tests__/lifecycle-boundaries.test.ts`
- `packages/eval/src/__tests__/provider-admission-integration.test.ts`
For a checkout such as:
~~~text
/Users/example/Documents/New project/maka
~~~
`.pathname` produces a value containing `%20`:
~~~text
/Users/example/Documents/New%20project/maka/...
~~~
That URL pathname is not decoded back into a filesystem path before it is passed to Node. The wrapper process therefore fails to start.
## Reproduction
Reproduced against `main` at:
~~~text
fde5fb078056be88eeb41733c8772024e6170851
~~~
1. Check out the repository under a path containing a space.
2. Install dependencies and build the repository.
3. Run:
~~~bash
node --test \
--test-name-pattern="the Maka shim projects only|eight-arm spec and wrappers" \
packages/eval/dist/__tests__/lifecycle-boundaries.test.js
~~~
The two selected tests fail consistently:
~~~text
the Maka shim projects only a completed subject as a zero exit
expected: 0
actual: 1
eight-arm spec and wrappers freeze the working provider contracts
expected: MAKA-EVAL-RESULT-V1
actual: <empty>
~~~
The same tests passed in three consecutive runs from a clean checkout whose path contained no spaces. They failed in three consecutive runs from a clean checkout whose path contained spaces.
## Cause
The tests use values such as:
~~~ts
const wrapper = new URL('../harbor-external-subject.js', import.meta.url);
await execFileAsync(process.execPath, [wrapper.pathname, ...args]);
~~~
`URL.pathname` is a URL-encoded pathname, not a platform filesystem path.
The same pattern is also used when launching `harbor-maka-subject.js` and in several provider-admission integration cases.
## Suggested fix
Convert file URLs with Node's `fileURLToPath()` before passing them to `execFile()` or `spawn()`:
~~~ts
import { fileURLToPath } from 'node:url';
const wrapperPath = fileURLToPath(
new URL('../harbor-external-subject.js', import.meta.url),
);
await execFileAsync(process.execPath, [wrapperPath, ...args]);
~~~
Apply the same conversion to all wrapper and shim paths passed to child-process APIs in the affected Eval tests.
<details>
<summary>简体中文</summary>
## 问题
当仓库检出路径包含空格或其他需要 URL 编码的字符时,部分 Eval 测试会失败。
受影响的测试使用 `new URL(..., import.meta.url).pathname` 构造 wrapper 路径,并将结果直接传给 `child_process`:
- `packages/eval/src/__tests__/lifecycle-boundaries.test.ts`
- `packages/eval/src/__tests__/provider-admission-integration.test.ts`
例如仓库位于:
~~~text
/Users/example/Documents/New project/maka
~~~
`.pathname` 返回的路径包含 `%20`:
~~~text
/Users/example/Documents/New%20project/maka/...
~~~
该 URL pathname 在传给 Node 之前没有转换回文件系统路径,因此 wrapper 子进程无法启动。
## 复现
已在以下 `main` 提交上复现:
~~~text
fde5fb078056be88eeb41733c8772024e6170851
~~~
1. 将仓库检出到包含空格的路径。
2. 安装依赖并构建仓库。
3. 运行:
~~~bash
node --test \
--test-name-pattern="the Maka shim projects only|eight-arm spec and wrappers" \
packages/eval/dist/__tests__/lifecycle-boundaries.test.js
~~~
两个测试会稳定失败:
~~~text
the Maka shim projects only a completed subject as a zero exit
预期:0
实际:1
eight-arm spec and wrappers freeze the working provider contracts
预期:MAKA-EVAL-RESULT-V1
实际:空输出
~~~
在路径不含空格的干净检出中,两个测试连续运行三次均通过;在路径包含空格的干净检出中,连续运行三次均失败。
## 原因
测试代码使用了类似以下写法:
~~~ts
const wrapper = new URL('../harbor-external-subject.js', import.meta.url);
await execFileAsync(process.execPath, [wrapper.pathname, ...args]);
~~~
`URL.pathname` 是经过 URL 编码的 pathname,并不是平台文件系统路径。
启动 `harbor-maka-subject.js` 以及部分 provider-admission 集成测试时也使用了相同模式。
## 建议修复
在将文件 URL 传给 `execFile()` 或 `spawn()` 前,使用 Node 的 `fileURLToPath()` 进行转换:
~~~ts
import { fileURLToPath } from 'node:url';
const wrapperPath = fileURLToPath(
new URL('../harbor-external-subject.js', import.meta.url),
);
await execFileAsync(process.execPath, [wrapperPath, ...args]);
~~~
对受影响 Eval 测试中传给子进程 API 的所有 wrapper 和 shim 路径应用相同转换。
</details>
AI assistance: OpenAI Codex assisted with source inspection, clean-worktree reproduction, and drafting this issue. I reviewed the reproduction, proposed fix, and final text.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org
Re: [I] fix(eval): decode file URLs before launching test wrappers [maka]
Posted by "me2seeks (via GitHub)" <gi...@apache.org>.
me2seeks closed issue #4757: fix(eval): decode file URLs before launching test wrappers
URL: https://github.com/apache/maka/issues/4757
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org
Re: [I] fix(eval): decode file URLs before launching test wrappers [maka]
Posted by "sunrioa (via GitHub)" <gi...@apache.org>.
sunrioa commented on issue #4757:
URL: https://github.com/apache/maka/issues/4757#issuecomment-5538518470
take
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org