fix(registry): 적재에 실패한 레지스트리 source는 그 오류를 함께 적는다

문제: check-registries는 레지스트리 source 모듈의 import 오류를 삼키고
"missing registry source <path>"만 남겼다. 파일은 있는데 그 안의 import가
깨진 경우에도 파일이 없는 것처럼 보였다. 6ea9e4a의 원인(옮긴 export를 예전
경로에서 가져온 fixture)도 이 메시지만으로는 찾을 수 없어 임시 출력을 넣어
찾았다.

방법: source 경로가 있는데 적재가 실패하면 오류 메시지 첫 줄을 실패 문장
뒤에 붙인다. 파일이 없을 때의 문장은 그대로다(release-artifacts·json-schema
테스트가 그 문장을 쓴다). 스택 전체를 붙이는 방법은 버렸다. 산출물 JSON의
failures가 커지고 경로가 실행 환경마다 달라진다.

위험: 다운스트림이 이 실패 문장을 정확히 비교하면 달라진다. 파일이 없는
경우의 문장은 바뀌지 않았다.

검증: tests/unit/registry-governance.test.ts에 "있지만 import가 깨진 source"
테스트를 더했다. 수정 전 실패(1 failed), 수정 뒤 10건 통과. check-registries
PASS, eslint, tsc(node) 통과.
This commit is contained in:
DongHyeonka
2026-11-03 02:15:31 +09:00
parent 6ea9e4afa6
commit 3ea7c37ed0
2 changed files with 57 additions and 2 deletions
+5 -2
View File
@@ -368,8 +368,11 @@ for (const specification of governance.registries) {
`${pathToFileURL(path.resolve(sourcePath)).href}?registry-check=${Date.now()}`
)) as Record<string, unknown>;
rows = registryModule[specification.exportName];
} catch {
if (!rows) failures.push(`missing registry source ${specification.path}`);
} catch (error) {
// A source that exists but fails to load names its error, so a broken
// import in a feature contract is not reported as a missing file.
const reason = sourcePath && error instanceof Error ? `: ${error.message.split("\n")[0]}` : "";
if (!rows) failures.push(`missing registry source ${specification.path}${reason}`);
}
const registryRows = projectRegistryRows(specification, rows);
+52
View File
@@ -484,4 +484,56 @@ describe("registry governance manifest", () => {
await rm(directory, { recursive: true, force: true });
}
});
it("names the load error of a registry source that exists but fails to import", async () => {
const directory = await mkdtemp(path.join(tmpdir(), "registry-source-error-"));
try {
await mkdir(path.join(directory, "src"), { recursive: true });
await writeFile(
path.join(directory, "src/broken.ts"),
'import { missingExport } from "./absent.ts";\nexport const ROWS = [missingExport];\n',
);
await writeFile(path.join(directory, "src/absent.ts"), "export const other = 1;\n");
await writeFile(
path.join(directory, "governance.json"),
JSON.stringify({
schemaVersion: 1,
sourceDirectories: [],
registries: [
{
registryId: "FIXTURE-BROKEN",
path: "src/broken.ts",
exportName: "ROWS",
owner: "fixture",
requiredFields: ["id"],
uniqueFields: ["id"],
},
],
compatibilityImpact: {
allowed: ["none", "additive", "behavior-change", "breaking"],
current: "none",
},
}),
);
const result = spawnSync(
process.execPath,
[
path.resolve("scripts/check-registries.ts"),
"--governance",
"governance.json",
"--no-baseline",
"--artifact",
"out.json",
],
{ cwd: directory, encoding: "utf8" },
);
expect(result.status).toBe(1);
expect(`${result.stdout}${result.stderr}`).toContain(
"missing registry source src/broken.ts: The requested module './absent.ts' does not provide an export named 'missingExport'",
);
} finally {
await rm(directory, { recursive: true, force: true });
}
});
});