























@@ -88,7 +88,13 @@ describe("diagnostic stability bundles", () => {
8888reason: "json_body_limit",
8989});
909091-const error = Object.assign(new Error("contains secret message"), { code: "ERR_TEST" });
91+const secret = "sk-1234567890abcdef";
92+const error = Object.assign(
93+new Error(
94+`Startup failed: OPENAI_API_KEY=${secret} while opening google/web-search-contract-api.js`,
95+),
96+{ code: "ERR_TEST" },
97+);
9298const result = writeDiagnosticStabilityBundleSync({
9399reason: "gateway.restart_startup_failed",
94100 error,
@@ -122,9 +128,11 @@ describe("diagnostic stability bundles", () => {
122128});
123129expect(bundle.snapshot.events[0]).not.toHaveProperty("chatId");
124130expect(bundle.snapshot.events[0]).not.toHaveProperty("error");
131+expect(bundle.error?.message).toContain("google/web-search-contract-api.js");
132+expect(bundle.error?.message).not.toContain(secret);
125133expect(raw).not.toContain("chat-secret");
126134expect(raw).not.toContain("message body");
127-expect(raw).not.toContain("contains secret message");
135+expect(raw).not.toContain(secret);
128136expect(raw).not.toContain(os.hostname());
129137});
130138@@ -158,13 +166,14 @@ describe("diagnostic stability bundles", () => {
158166error: {
159167name: "Error",
160168code: "ERR_CONFIG_PARSE",
169+message: "raw startup config payload",
161170},
162171snapshot: {
163172count: 0,
164173events: [],
165174},
166175});
167-expect(raw).not.toContain("raw startup config payload");
176+expect(raw).not.toContain("stack");
168177});
169178170179it("registers a fatal hook only while installed", () => {
@@ -242,7 +251,7 @@ describe("diagnostic stability bundles", () => {
242251error: {
243252name: "private error name",
244253code: "ERR_TEST",
245-message: "error-message-secret",
254+message: "OPENAI_API_KEY=sk-1234567890abcdef",
246255},
247256});
248257Object.assign(bundle.process as Record<string, unknown>, {
@@ -284,7 +293,9 @@ describe("diagnostic stability bundles", () => {
284293}
285294expect(result.bundle.reason).toBe("unknown");
286295expect(result.bundle.host).toEqual({ hostname: "<redacted-hostname>" });
287-expect(result.bundle.error).toEqual({ code: "ERR_TEST" });
296+expect(result.bundle.error?.code).toBe("ERR_TEST");
297+expect(result.bundle.error?.message).toContain("OPENAI_API_KEY=");
298+expect(result.bundle.error?.message).not.toContain("sk-1234567890abcdef");
288299expect(result.bundle.snapshot.events[0]).toEqual({
289300seq: 1,
290301ts: 1,
@@ -297,7 +308,7 @@ describe("diagnostic stability bundles", () => {
297308"private reason",
298309"top-level-secret",
299310"private error name",
300-"error-message-secret",
311+"sk-1234567890abcdef",
301312"process-command-secret",
302313"private-hostname",
303314"host-extra-secret",
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。