fix: repair Telegram allowlist DM migrations (#27936) (thanks @widingmarcus-cyber)

This commit is contained in:
Peter Steinberger
2026-02-26 23:36:33 +01:00
parent 2c6b078ff0
commit 1d43202930
5 changed files with 240 additions and 9 deletions

View File

@@ -452,6 +452,50 @@ describe("doctor config flow", () => {
expect(cfg.channels.discord.accounts.work.allowFrom).toEqual(["*"]);
});
it('repairs dmPolicy="allowlist" by restoring allowFrom from pairing store on repair', async () => {
const result = await withTempHome(async (home) => {
const configDir = path.join(home, ".openclaw");
const credentialsDir = path.join(configDir, "credentials");
await fs.mkdir(credentialsDir, { recursive: true });
await fs.writeFile(
path.join(configDir, "openclaw.json"),
JSON.stringify(
{
channels: {
telegram: {
botToken: "fake-token",
dmPolicy: "allowlist",
},
},
},
null,
2,
),
"utf-8",
);
await fs.writeFile(
path.join(credentialsDir, "telegram-allowFrom.json"),
JSON.stringify({ version: 1, allowFrom: ["12345"] }, null, 2),
"utf-8",
);
return await loadAndMaybeMigrateDoctorConfig({
options: { nonInteractive: true, repair: true },
confirm: async () => false,
});
});
const cfg = result.cfg as {
channels: {
telegram: {
dmPolicy: string;
allowFrom: string[];
};
};
};
expect(cfg.channels.telegram.dmPolicy).toBe("allowlist");
expect(cfg.channels.telegram.allowFrom).toEqual(["12345"]);
});
it("migrates legacy toolsBySender keys to typed id entries on repair", async () => {
const result = await runDoctorConfigWithInput({
repair: true,