Skip to content

Commit e68998e

Browse files
author
xin
committed
fix(doctor): skip top-level allowlist scan when active per-account scopes exist
The empty-allowlist doctor scanner treated the top-level channel config as its own standalone account, producing false 'empty allowlist' warnings when every active account under that channel supplied its own populated groupAllowFrom / allowFrom. Fix: only run the top-level check when there are no active (non-disabled) account entries. When accounts exist, the top-level config acts only as a parent fallback — matching runtime resolution semantics. Closes #92684
1 parent 0314819 commit e68998e

2 files changed

Lines changed: 37 additions & 3 deletions

File tree

‎src/commands/doctor/shared/empty-allowlist-scan.test.ts‎

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ describe("doctor empty allowlist policy scan", () => {
3232
);
3333

3434
expect(warnings).toEqual([
35-
'- channels.signal.dmPolicy is "allowlist" but allowFrom is empty — all DMs will be blocked. Add sender IDs to channels.signal.allowFrom, or run "openclaw doctor --fix" to auto-migrate from pairing store when entries exist.',
3635
'- channels.signal.accounts.work.dmPolicy is "allowlist" but allowFrom is empty — all DMs will be blocked. Add sender IDs to channels.signal.accounts.work.allowFrom, or run "openclaw doctor --fix" to auto-migrate from pairing store when entries exist.',
3736
]);
3837
});
@@ -59,6 +58,33 @@ describe("doctor empty allowlist policy scan", () => {
5958
]);
6059
});
6160

61+
it("does not warn top-level empty groupAllowFrom when active accounts have their own lists", () => {
62+
const warnings = scanEmptyAllowlistPolicyWarnings(
63+
{
64+
channels: {
65+
telegram: {
66+
groupPolicy: "allowlist",
67+
// top-level empty — should not warn because accounts have own lists
68+
accounts: {
69+
work: {
70+
groupAllowFrom: ["+15551234567"],
71+
dmPolicy: "open",
72+
},
73+
personal: {
74+
groupAllowFrom: ["+15557654321"],
75+
dmPolicy: "open",
76+
},
77+
},
78+
},
79+
},
80+
},
81+
{ doctorFixCommand: "openclaw doctor --fix" },
82+
);
83+
84+
// No warnings: top-level parent skipped, accounts have non-empty groupAllowFrom
85+
expect(warnings).toEqual([]);
86+
});
87+
6288
it("skips disabled channel and account entries", () => {
6389
const extraWarningsForAccount = vi.fn(({ prefix }) => [`extra:${prefix}`]);
6490

‎src/commands/doctor/shared/empty-allowlist-scan.ts‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,26 +88,34 @@ export function scanEmptyAllowlistPolicyWarnings(
8888
if (isDisabledRecord(channelConfig)) {
8989
continue;
9090
}
91-
checkAccount(channelConfig, `channels.${channelName}`, channelName);
92-
9391
const accounts = asObjectRecord(channelConfig.accounts);
9492
if (!accounts) {
93+
checkAccount(channelConfig, `channels.${channelName}`, channelName);
9594
continue;
9695
}
96+
let hasActiveAccount = false;
9797
for (const [accountId, account] of Object.entries(accounts)) {
9898
if (!account || typeof account !== "object") {
9999
continue;
100100
}
101101
if (isDisabledRecord(account)) {
102102
continue;
103103
}
104+
hasActiveAccount = true;
104105
checkAccount(
105106
account as DoctorAccountRecord,
106107
`channels.${channelName}.accounts.${accountId}`,
107108
channelName,
108109
channelConfig,
109110
);
110111
}
112+
// When active per-account scopes exist, the top-level channel config acts only
113+
// as a parent fallback for allowlist resolution, not as its own standalone record.
114+
// Avoid false "empty allowlist" warnings for the parent when every active account
115+
// supplies its own populated list.
116+
if (!hasActiveAccount) {
117+
checkAccount(channelConfig, `channels.${channelName}`, channelName);
118+
}
111119
}
112120

113121
return warnings;

0 commit comments

Comments
 (0)