Skip to content

Commit 584cd74

Browse files
steipetewangyan2026
andcommitted
fix(pairing): keep default suffix literal
Co-authored-by: WangYan <[email protected]>
1 parent 96758aa commit 584cd74

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

‎src/infra/state-migrations.channel-pairing.test.ts‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,27 @@ describe("legacy channel pairing state migration", () => {
274274
});
275275
});
276276

277+
it("leaves nonliteral default filename suffixes unresolved", async () => {
278+
const { env, sourceDir } = await createFixture();
279+
const filePath = path.join(sourceDir, "telegram-DEFAULT-allowFrom.json");
280+
writeJson(filePath, { version: 1, allowFrom: ["1003"] });
281+
282+
const detected = detectLegacyChannelPairingState({
283+
sourceDir,
284+
configuredAccountIds: { telegram: ["default"] },
285+
});
286+
const result = migrateLegacyChannelPairingState({ detected, env });
287+
288+
expect(result.changes).toEqual([]);
289+
expect(result.warnings).toEqual([
290+
expect.stringContaining(
291+
"Legacy channel allowFrom channel/account is unresolved; left in place",
292+
),
293+
]);
294+
expect(fs.existsSync(filePath)).toBe(true);
295+
expect(readChannelPairingStateSnapshot("telegram", env).allowFrom).toEqual({});
296+
});
297+
277298
it("does not infer default accounts for external channels", async () => {
278299
const { env, sourceDir } = await createFixture();
279300
const filePath = path.join(sourceDir, "custom-channel-default-allowFrom.json");

‎src/infra/state-migrations.channel-pairing.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,9 @@ function parseAllowFromFilename(
138138
const matchingAccountIds = (accountIds[channel] ?? []).filter((accountId) => {
139139
try {
140140
safeAccountKey(accountId);
141+
if (accountId === DEFAULT_ACCOUNT_ID && accountKey !== DEFAULT_ACCOUNT_ID) {
142+
return false;
143+
}
141144
return accountId.toLowerCase() === accountKey.toLowerCase();
142145
} catch {
143146
// One invalid configured candidate must not abort every legacy migration.

0 commit comments

Comments
 (0)