fix(config): align default.yaml with server schema
This commit is contained in:
@@ -72,6 +72,28 @@ telegram:
|
||||
expect(configValidates?.status).toBe('fail');
|
||||
});
|
||||
|
||||
it('warns when deprecated server.tailscale_only key is present', async () => {
|
||||
mkdirSync(testDir, { recursive: true });
|
||||
const configPath = join(testDir, 'config.yaml');
|
||||
writeFileSync(configPath, `
|
||||
telegram:
|
||||
bot_token: "test-token"
|
||||
allowed_chat_ids: [123]
|
||||
server:
|
||||
tailscale_only: true
|
||||
models:
|
||||
default:
|
||||
provider: anthropic
|
||||
model: claude-sonnet
|
||||
`);
|
||||
|
||||
const ctx: DoctorContext = { configPath, dataDir: testDir };
|
||||
const results = await runChecks(ctx);
|
||||
|
||||
const deprecated = results.find(r => r.label.includes('deprecated keys'));
|
||||
expect(deprecated?.status).toBe('warn');
|
||||
});
|
||||
|
||||
it('reports PASS for writable data directory', async () => {
|
||||
mkdirSync(testDir, { recursive: true });
|
||||
const configPath = join(testDir, 'config.yaml');
|
||||
|
||||
@@ -71,6 +71,30 @@ const checkConfigValidates: Check = async (ctx) => {
|
||||
}
|
||||
};
|
||||
|
||||
const checkDeprecatedConfigKeys: Check = async (ctx) => {
|
||||
if (!existsSync(ctx.configPath)) {
|
||||
return { status: 'skip', label: 'Config deprecated keys', detail: '(no config file)' };
|
||||
}
|
||||
|
||||
try {
|
||||
const raw = readFileSync(ctx.configPath, 'utf-8');
|
||||
const parsed = parse(raw) as any;
|
||||
const tailscaleOnly = Boolean(parsed?.server && typeof parsed.server === 'object' && 'tailscale_only' in parsed.server);
|
||||
|
||||
if (tailscaleOnly) {
|
||||
return {
|
||||
status: 'warn',
|
||||
label: 'Config deprecated keys',
|
||||
detail: 'server.tailscale_only is deprecated/ignored; use server.tailscale.* + server.localhost instead',
|
||||
};
|
||||
}
|
||||
|
||||
return { status: 'pass', label: 'Config deprecated keys' };
|
||||
} catch {
|
||||
return { status: 'skip', label: 'Config deprecated keys', detail: '(could not read/parse config)' };
|
||||
}
|
||||
};
|
||||
|
||||
const checkEnvVars: Check = async (ctx) => {
|
||||
if (!existsSync(ctx.configPath)) {
|
||||
return { status: 'skip', label: 'Env vars resolved', detail: '(no config file)' };
|
||||
@@ -492,6 +516,7 @@ const allChecks: Check[] = [
|
||||
checkConfigExists,
|
||||
checkOverlayExists,
|
||||
checkConfigParses,
|
||||
checkDeprecatedConfigKeys,
|
||||
checkConfigValidates,
|
||||
checkEnvVars,
|
||||
checkDataDir,
|
||||
|
||||
Reference in New Issue
Block a user