fix: stabilize channel migration
This commit is contained in:
@@ -2003,11 +2003,14 @@ describe("config preservation on validation failure", () => {
|
||||
const { readConfigFileSnapshot } = await import("./config.js");
|
||||
const snap = await readConfigFileSnapshot();
|
||||
|
||||
expect(snap.valid).toBe(false);
|
||||
expect(snap.legacyIssues.length).toBeGreaterThan(0);
|
||||
expect(snap.valid).toBe(true);
|
||||
expect(snap.legacyIssues).toHaveLength(0);
|
||||
expect((snap.config as Record<string, unknown>).customData).toEqual({
|
||||
preserved: true,
|
||||
});
|
||||
expect(snap.config.channels?.whatsapp?.allowFrom).toEqual([
|
||||
"+15555550123",
|
||||
]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -352,11 +352,15 @@ export function createConfigIO(overrides: ConfigIoDeps = {}) {
|
||||
}
|
||||
|
||||
const migrated = applyLegacyMigrations(resolved);
|
||||
const resolvedConfig = migrated.next ?? resolved;
|
||||
const legacyIssues = findLegacyConfigIssues(resolvedConfig);
|
||||
const resolvedConfigRaw = migrated.next ?? resolved;
|
||||
const legacyIssues = findLegacyConfigIssues(resolvedConfigRaw);
|
||||
|
||||
const validated = validateConfigObject(resolvedConfig);
|
||||
const validated = validateConfigObject(resolvedConfigRaw);
|
||||
if (!validated.ok) {
|
||||
const resolvedConfig =
|
||||
typeof resolvedConfigRaw === "object" && resolvedConfigRaw !== null
|
||||
? (resolvedConfigRaw as ClawdbotConfig)
|
||||
: {};
|
||||
return {
|
||||
path: configPath,
|
||||
exists: true,
|
||||
|
||||
Reference in New Issue
Block a user