From 3ea7c37ed028f80b78d9eb55015ab8f446309fc5 Mon Sep 17 00:00:00 2001 From: DongHyeonka Date: Tue, 3 Nov 2026 02:15:31 +0900 Subject: [PATCH] =?UTF-8?q?fix(registry):=20=EC=A0=81=EC=9E=AC=EC=97=90=20?= =?UTF-8?q?=EC=8B=A4=ED=8C=A8=ED=95=9C=20=EB=A0=88=EC=A7=80=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=EB=A6=AC=20source=EB=8A=94=20=EA=B7=B8=20=EC=98=A4?= =?UTF-8?q?=EB=A5=98=EB=A5=BC=20=ED=95=A8=EA=BB=98=20=EC=A0=81=EB=8A=94?= =?UTF-8?q?=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 문제: check-registries는 레지스트리 source 모듈의 import 오류를 삼키고 "missing registry source "만 남겼다. 파일은 있는데 그 안의 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) 통과. --- scripts/check-registries.ts | 7 +++- tests/unit/registry-governance.test.ts | 52 ++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 2 deletions(-) diff --git a/scripts/check-registries.ts b/scripts/check-registries.ts index 347000d3..b34bba0c 100644 --- a/scripts/check-registries.ts +++ b/scripts/check-registries.ts @@ -368,8 +368,11 @@ for (const specification of governance.registries) { `${pathToFileURL(path.resolve(sourcePath)).href}?registry-check=${Date.now()}` )) as Record; 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); diff --git a/tests/unit/registry-governance.test.ts b/tests/unit/registry-governance.test.ts index 3f547496..8c2e0586 100644 --- a/tests/unit/registry-governance.test.ts +++ b/tests/unit/registry-governance.test.ts @@ -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 }); + } + }); });