fix(line): use configured field in collectStatusIssues instead of raw token

collectStatusIssues previously checked account.channelAccessToken directly,
but this field is stripped by projectSafeChannelAccountSnapshotFields for
security. This caused 'openclaw status' to always report WARN even when the
token is valid and the LINE provider starts successfully.

Use account.configured instead, which is already computed by
buildChannelAccountSnapshot and correctly reflects whether credentials
are present. This is consistent with how other channels (e.g. Telegram)
implement their status checks.

Fixes #45693
This commit is contained in:
劉超
2026-03-14 12:39:49 +09:00
committed by Peter Steinberger
parent b23ed7530b
commit 03941e2dbf
2 changed files with 68 additions and 11 deletions

View File

@@ -0,0 +1,63 @@
import { describe, expect, it } from "vitest";
import type { ChannelAccountSnapshot } from "../api.js";
import { linePlugin } from "./channel.js";
function collectIssues(accounts: ChannelAccountSnapshot[]) {
const collect = linePlugin.status?.collectStatusIssues;
if (!collect) {
throw new Error("LINE plugin status collector is unavailable");
}
return collect(accounts);
}
describe("linePlugin status.collectStatusIssues", () => {
it("does not warn when a sanitized snapshot is configured", () => {
expect(
collectIssues([
{
accountId: "default",
configured: true,
tokenSource: "env",
},
]),
).toEqual([]);
});
it("reports missing access token when the snapshot is unconfigured and tokenSource is none", () => {
expect(
collectIssues([
{
accountId: "default",
configured: false,
tokenSource: "none",
},
]),
).toEqual([
{
channel: "line",
accountId: "default",
kind: "config",
message: "LINE channel access token not configured",
},
]);
});
it("reports missing secret when the snapshot is unconfigured but a token source exists", () => {
expect(
collectIssues([
{
accountId: "default",
configured: false,
tokenSource: "env",
},
]),
).toEqual([
{
channel: "line",
accountId: "default",
kind: "config",
message: "LINE channel secret not configured",
},
]);
});
});

View File

@@ -83,20 +83,15 @@ export const linePlugin: ChannelPlugin<ResolvedLineAccount> = createChatChannelP
const issues: ChannelStatusIssue[] = [];
for (const account of accounts) {
const accountId = account.accountId ?? DEFAULT_ACCOUNT_ID;
if (!account.channelAccessToken?.trim()) {
if (account.configured === false) {
const hasToken = account.tokenSource != null && account.tokenSource !== "none";
issues.push({
channel: "line",
accountId,
kind: "config",
message: "LINE channel access token not configured",
});
}
if (!account.channelSecret?.trim()) {
issues.push({
channel: "line",
accountId,
kind: "config",
message: "LINE channel secret not configured",
message: hasToken
? "LINE channel secret not configured"
: "LINE channel access token not configured",
});
}
}
@@ -520,5 +515,4 @@ export const linePlugin: ChannelPlugin<ResolvedLineAccount> = createChatChannelP
accountId: accountId ?? undefined,
}),
}),
},
});