diff --git a/extensions/line/src/channel.startup.test.ts b/extensions/line/src/channel.startup.test.ts index e4de0f38e3b..f5a6dd7310e 100644 --- a/extensions/line/src/channel.startup.test.ts +++ b/extensions/line/src/channel.startup.test.ts @@ -129,3 +129,54 @@ describe("linePlugin gateway.startAccount", () => { await task; }); }); + +describe("linePlugin status", () => { + it("does not report missing token or secret when snapshot came from file-backed config", async () => { + const snapshot = await linePlugin.status?.buildAccountSnapshot?.({ + account: { + accountId: "default", + name: "Default", + enabled: true, + channelAccessToken: "token-from-file", + channelSecret: "secret-from-file", + tokenSource: "file", + config: {} as ResolvedLineAccount["config"], + } as never, + cfg: {} as OpenClawConfig, + runtime: undefined, + probe: undefined, + audit: undefined, + }); + + expect(snapshot?.configured).toBe(true); + expect(linePlugin.status?.collectStatusIssues?.([snapshot as never])).toEqual([]); + }); + + it("keeps per-field warnings when only one credential is missing", async () => { + const snapshot = await linePlugin.status?.buildAccountSnapshot?.({ + account: { + accountId: "default", + name: "Default", + enabled: true, + channelAccessToken: " ", + channelSecret: "secret-from-file", + tokenSource: "file", + config: {} as ResolvedLineAccount["config"], + } as never, + cfg: {} as OpenClawConfig, + runtime: undefined, + probe: undefined, + audit: undefined, + }); + + expect(snapshot?.configured).toBe(false); + expect(linePlugin.status?.collectStatusIssues?.([snapshot as never])).toEqual([ + { + channel: "line", + accountId: "default", + kind: "config", + message: "LINE channel access token not configured", + }, + ]); + }); +}); diff --git a/extensions/line/src/channel.ts b/extensions/line/src/channel.ts index 9388579ab38..37fbda8c54a 100644 --- a/extensions/line/src/channel.ts +++ b/extensions/line/src/channel.ts @@ -569,7 +569,7 @@ export const linePlugin: ChannelPlugin = { const issues: ChannelStatusIssue[] = []; for (const account of accounts) { const accountId = account.accountId ?? DEFAULT_ACCOUNT_ID; - if (!account.channelAccessToken?.trim()) { + if (account.channelAccessTokenConfigured === false) { issues.push({ channel: "line", accountId, @@ -577,7 +577,7 @@ export const linePlugin: ChannelPlugin = { message: "LINE channel access token not configured", }); } - if (!account.channelSecret?.trim()) { + if (account.channelSecretConfigured === false) { issues.push({ channel: "line", accountId, @@ -605,6 +605,8 @@ export const linePlugin: ChannelPlugin = { }); return { ...base, + channelAccessTokenConfigured: Boolean(account.channelAccessToken?.trim()), + channelSecretConfigured: Boolean(account.channelSecret?.trim()), tokenSource: account.tokenSource, mode: "webhook", };