관리자 서버 진단에 lease 상태와 영속 장애 이력 추가

This commit is contained in:
2026-09-09 23:36:16 +00:00
parent 9c73085353
commit a00f46dfc8
19 changed files with 627 additions and 43 deletions
@@ -0,0 +1,23 @@
import { describe, expect, it } from 'vitest';
import { describeRuntimeError } from '../src/gateway/runtimeDiagnostics.js';
describe('runtime failure records', () => {
it('keeps the cause and frames while removing connection and authentication values', () => {
const error = new Error(
'database failed postgresql://admin:private@host/db password="hidden value" token=abc Bearer xyz'
);
error.stack = `${error.message}\n at flush (/srv/app/flush.ts:42:7)`;
const record = describeRuntimeError(error);
expect(record.code).toBe('Error');
expect(record.message).toContain('database failed');
for (const secret of ['private', 'hidden value', 'abc', 'xyz'])
expect(JSON.stringify(record)).not.toContain(secret);
expect(record.frames).toEqual([' at flush (/srv/app/flush.ts:42:7)']);
});
it('bounds untrusted messages and stack depth', () => {
const error = new Error('x'.repeat(4000));
error.stack = Array.from({ length: 30 }, () => ' at run (/app/run.ts:1:1)').join('\n');
expect(describeRuntimeError(error).message).toHaveLength(2000);
expect(describeRuntimeError(error).frames).toHaveLength(8);
});
});