惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

罗磊的独立博客
L
LangChain Blog
aimingoo的专栏
aimingoo的专栏
IT之家
IT之家
B
Blog
博客园_首页
博客园 - 司徒正美
有赞技术团队
有赞技术团队
博客园 - 聂微东
I
InfoQ
美团技术团队
GbyAI
GbyAI
阮一峰的网络日志
阮一峰的网络日志
H
Help Net Security
大猫的无限游戏
大猫的无限游戏
MyScale Blog
MyScale Blog
WordPress大学
WordPress大学
The GitHub Blog
The GitHub Blog
A
About on SuperTechFans
人人都是产品经理
人人都是产品经理
Microsoft Azure Blog
Microsoft Azure Blog
Engineering at Meta
Engineering at Meta
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
The Cloudflare Blog

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(discord): harden account and binding routing · opencl...
steipete · 2026-04-29 · via Recent Commits to openclaw:main

@@ -1,10 +1,17 @@

1-

import { describe, expect, it } from "vitest";

1+

import { afterEach, describe, expect, it, vi } from "vitest";

22

import {

33

createDiscordActionGate,

4+

isDiscordAccountEnabledForRuntime,

5+

listEnabledDiscordAccounts,

46

resolveDiscordAccount,

7+

resolveDiscordAccountDisabledReason,

58

resolveDiscordMaxLinesPerMessage,

69

} from "./accounts.js";

71011+

afterEach(() => {

12+

vi.unstubAllEnvs();

13+

});

14+815

describe("resolveDiscordAccount allowFrom precedence", () => {

916

it("uses configured defaultAccount when accountId is omitted", () => {

1017

const resolved = resolveDiscordAccount({

@@ -161,3 +168,80 @@ describe("resolveDiscordMaxLinesPerMessage", () => {

161168

expect(resolved).toBe(80);

162169

});

163170

});

171+172+

describe("Discord duplicate-token account filtering", () => {

173+

it("keeps the config-token account over default env fallback when tokens collide", () => {

174+

vi.stubEnv("DISCORD_BOT_TOKEN", "same-token");

175+

const cfg = {

176+

channels: {

177+

discord: {

178+

accounts: {

179+

work: {

180+

token: "same-token",

181+

},

182+

},

183+

},

184+

},

185+

};

186+187+

const defaultAccount = resolveDiscordAccount({ cfg, accountId: "default" });

188+

const workAccount = resolveDiscordAccount({ cfg, accountId: "work" });

189+190+

expect(isDiscordAccountEnabledForRuntime(defaultAccount, cfg)).toBe(false);

191+

expect(resolveDiscordAccountDisabledReason(defaultAccount, cfg)).toBe(

192+

'duplicate bot token; using account "work"',

193+

);

194+

expect(isDiscordAccountEnabledForRuntime(workAccount, cfg)).toBe(true);

195+

expect(listEnabledDiscordAccounts(cfg).map((account) => account.accountId)).toEqual(["work"]);

196+

});

197+198+

it("keeps the first enabled account when duplicate tokens have the same source", () => {

199+

const cfg = {

200+

channels: {

201+

discord: {

202+

accounts: {

203+

first: {

204+

token: "same-token",

205+

},

206+

second: {

207+

token: "same-token",

208+

},

209+

},

210+

},

211+

},

212+

};

213+214+

const firstAccount = resolveDiscordAccount({ cfg, accountId: "first" });

215+

const secondAccount = resolveDiscordAccount({ cfg, accountId: "second" });

216+217+

expect(isDiscordAccountEnabledForRuntime(firstAccount, cfg)).toBe(true);

218+

expect(isDiscordAccountEnabledForRuntime(secondAccount, cfg)).toBe(false);

219+

expect(resolveDiscordAccountDisabledReason(secondAccount, cfg)).toBe(

220+

'duplicate bot token; using account "first"',

221+

);

222+

expect(listEnabledDiscordAccounts(cfg).map((account) => account.accountId)).toEqual(["first"]);

223+

});

224+225+

it("does not let disabled duplicate-token accounts suppress enabled accounts", () => {

226+

const cfg = {

227+

channels: {

228+

discord: {

229+

accounts: {

230+

disabled: {

231+

enabled: false,

232+

token: "same-token",

233+

},

234+

active: {

235+

token: "same-token",

236+

},

237+

},

238+

},

239+

},

240+

};

241+242+

const activeAccount = resolveDiscordAccount({ cfg, accountId: "active" });

243+244+

expect(isDiscordAccountEnabledForRuntime(activeAccount, cfg)).toBe(true);

245+

expect(listEnabledDiscordAccounts(cfg).map((account) => account.accountId)).toEqual(["active"]);

246+

});

247+

});