fix(bootstrap): 금지된 설정 키로 멈춘 부팅 오류에 그 키 이름을 싣는다

문제: 런타임 설정에 비밀처럼 보이는 키(`CLIENT_SECRET` 등)가 있으면
부팅이 CONFIG_SECRET_NAME_REJECTED로 멈추지만, 안전한 부팅 오류에는
buildId만 있고 어느 키인지가 없다. assertSafeConfigNames가 던진 오류의
message에는 키 이름이 있었지만 loadRuntimeConfig가 그 오류를 버렸다.
같은 파일의 스키마 실패는 키 이름을 invalidKeys로 싣는다.

고른 방법: assertSafeConfigNames가 UnsafeConfigNameError를 던지고 그
`key`에 거절한 키의 점 경로(`CAPABILITY_OVERRIDES.AUTH_TOKEN`,
`FEATURE_OVERRIDES.<id>.CLIENT_SECRET`)를 싣는다. 로더는 그 경로를
스키마 실패와 같은 SAFE_KEY_PATTERN으로 거른 뒤 invalidKeys에 넣는다.
오류 화면은 이미 invalidKeys를 "잘못된 설정 키"로 보인다. 값은 어디에도
싣지 않는다. 버린 대안: message에서 키를 정규식으로 다시 읽는 것.
message 문구가 바뀌면 조용히 빠진다.

위험·한계: 키 이름은 거절된 문서에서 온다. 그래서 길이·문자를 제한하고,
그 밖의 이름은 빼고 코드만 남긴다. 첫 번째로 걸린 키 하나만 싣는다
(검사가 첫 키에서 멈추는 동작은 그대로). assertSafeConfigNames의
시그니처와 message는 바꾸지 않았다. UnsafeConfigNameError는
src/contracts/env.ts에 새로 더한 export다(추가만).

검증: desktop batch에서 확인.
node scripts/run-vitest.ts run tests/runtime-schema/runtime-config.test.ts

Refs: 1103/07-04
This commit is contained in:
DongHyeonka
2026-11-05 22:08:22 +09:00
parent bfd9d50d2b
commit 2e1acb1f21
4 changed files with 92 additions and 9 deletions
+17 -3
View File
@@ -1,4 +1,8 @@
import { assertSafeConfigNames, getBuildConfig } from "../contracts/env.ts";
import {
assertSafeConfigNames,
getBuildConfig,
UnsafeConfigNameError,
} from "../contracts/env.ts";
import { checkReleaseCoherence } from "../platform/release/release-coherence.ts";
import {
BOOT_JSON_POLICIES,
@@ -21,7 +25,10 @@ export type BootConfigSafe = Readonly<{
buildId: string;
configSchemaVersion?: string;
releaseId?: string;
/** 09-04. Names of rejected keys (never their values), bounded. */
/**
* 09-04. Names of rejected keys (never their values), bounded: the keys the
* schema rejected, or (1103/07-04) the secret-looking key's dotted path.
*/
invalidKeys?: readonly string[];
supportReference: string;
}>;
@@ -117,9 +124,16 @@ export async function loadRuntimeConfig(
try {
assertSafeConfigNames(rawConfig);
} catch {
} catch (error) {
// 1103/07-04. The rejected key's name, never its value, tells an operator
// what to remove. It comes from the rejected document, so it is bounded
// like the schema failure's keys below.
const key = error instanceof UnsafeConfigNameError ? error.key : undefined;
throw new BootConfigError("CONFIG_SECRET_NAME_REJECTED", {
buildId: buildConfig.buildId,
...(key !== undefined && SAFE_KEY_PATTERN.test(key)
? { invalidKeys: Object.freeze([key]) }
: {}),
});
}