fix(config): detect top-level heartbeat as invalid config path (#30894)

Top-level `heartbeat` is not a valid config path but was silently
ignored, causing users to believe heartbeat.model was configured
when it was not. Add a legacy config rule so startup validation
surfaces a clear migration hint pointing to agents.defaults.heartbeat.

Fixes #30894
This commit is contained in:
xiwan
2026-03-03 15:28:57 +08:00
committed by Gustavo Madeira Santana
parent b7589b32a8
commit b8d4888f3b
2 changed files with 14 additions and 0 deletions

View File

@@ -274,6 +274,15 @@ describe("legacy config detection", () => {
},
);
});
it("flags top-level heartbeat as legacy in snapshot", async () => {
await withSnapshotForConfig(
{ heartbeat: { model: "anthropic/claude-3-5-haiku-20241022", every: "30m" } },
async (ctx) => {
expect(ctx.snapshot.valid).toBe(false);
expect(ctx.snapshot.legacyIssues.some((issue) => issue.path === "heartbeat")).toBe(true);
},
);
});
it("flags legacy provider sections in snapshot", async () => {
await withSnapshotForConfig({ whatsapp: { allowFrom: ["+1555"] } }, async (ctx) => {
expect(ctx.snapshot.valid).toBe(false);

View File

@@ -204,4 +204,9 @@ export const LEGACY_CONFIG_RULES: LegacyConfigRule[] = [
match: (value) => isLegacyGatewayBindHostAlias(value),
requireSourceLiteral: true,
},
{
path: ["heartbeat"],
message:
"top-level heartbeat is not a valid config path; use agents.defaults.heartbeat instead.",
},
];