Skip to content

fix(discord): ignore wildcard key in unresolved audit channels#32528

Closed
bmendonca3 wants to merge 1 commit intoopenclaw:mainfrom
bmendonca3:bm/discord-audit-ignore-wildcard-32517
Closed

fix(discord): ignore wildcard key in unresolved audit channels#32528
bmendonca3 wants to merge 1 commit intoopenclaw:mainfrom
bmendonca3:bm/discord-audit-ignore-wildcard-32517

Conversation

@bmendonca3
Copy link
Copy Markdown
Contributor

Summary

  • Problem: openclaw doctor / channels status --probe reports unresolvedChannels=1 for valid Discord guild channel wildcard config (channels.discord.guilds.<id>.channels."*").
  • Why it matters: this creates false-positive audit warnings for valid allow-all guild channel configuration.
  • What changed: Discord audit channel collection now excludes the * wildcard key from unresolved-channel counting, and a regression test covers wildcard-only guild config.
  • What did NOT change (scope boundary): allowlist matching, guild/channel routing, and channel permission probing behavior are unchanged.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

User-visible / Behavior Changes

  • openclaw doctor and openclaw channels status --probe no longer count Discord channel wildcard keys (*) as unresolved channel IDs.

Security Impact (required)

  • New permissions/capabilities? (No)
  • Secrets/tokens handling changed? (No)
  • New/changed network calls? (No)
  • Command/tool execution surface changed? (No)
  • Data access scope changed? (No)
  • If any Yes, explain risk + mitigation: N/A

Repro + Verification

Environment

  • OS: macOS (Darwin arm64)
  • Runtime/container: Node 22 + pnpm workspace tests
  • Model/provider: N/A
  • Integration/channel (if any): Discord
  • Relevant config (redacted):
{
  "channels": {
    "discord": {
      "guilds": {
        "1478116902202114240": {
          "channels": {
            "*": { "allow": true }
          }
        }
      }
    }
  }
}

Steps

  1. Configure Discord guild channel allowlist with wildcard-only entry (channels.discord.guilds.<guildId>.channels."*").
  2. Run Discord audit collection (collectDiscordAuditChannelIds) via doctor/status flows.
  3. Observe unresolved channel count.

Expected

  • Wildcard key is treated as valid config and does not increment unresolvedChannels.

Actual

  • * was treated as unresolved/non-numeric and incremented unresolvedChannels by 1.

Evidence

  • Failing test/log before + passing after
  • Trace/log snippets
  • Screenshot/recording
  • Perf numbers (if relevant)

Human Verification (required)

What you personally verified (not just CI), and how:

  • Verified scenarios:
    • pnpm vitest run src/discord/audit.test.ts passes, including new wildcard regression case.
    • Existing numeric/non-numeric unresolved counting case still passes.
  • Edge cases checked:
    • Wildcard-only channel map returns channelIds=[] and unresolvedChannels=0.
  • What you did not verify:
    • Full end-to-end Discord live API permission probing in a real guild.

Compatibility / Migration

  • Backward compatible? (Yes)
  • Config/env changes? (No)
  • Migration needed? (No)
  • If yes, exact upgrade steps: N/A

Failure Recovery (if this breaks)

  • How to disable/revert this change quickly: revert this PR commit.
  • Files/config to restore: src/discord/audit.ts, src/discord/audit.test.ts.
  • Known bad symptoms reviewers should watch for: wildcard keys wrongly reappear in unresolved count.

Risks and Mitigations

  • Risk: non-numeric keys other than wildcard could be accidentally excluded from unresolved count.
    • Mitigation: logic excludes only exact *; all other non-numeric keys remain unresolved and existing test coverage is retained.

@aisle-research-bot
Copy link
Copy Markdown

aisle-research-bot bot commented Mar 3, 2026

🤖 We're reviewing this PR with Aisle

We're running a security check on the changes in this PR now. This usually takes a few minutes. ⌛
We'll post the results here as soon as they're ready.

Progress:

  • Analysis
  • Triage
  • Finalization

Latest run failed. Keeping previous successful results. Trace ID: 019cb1f1800c073e978ee0be8909e79c.

Last updated on: 2026-03-03T04:25:31Z

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 3, 2026

Greptile Summary

This PR fixes a false-positive unresolvedChannels count in collectDiscordAuditChannelIds when a Discord guild is configured with a wildcard channel key ("*"). Previously, the count was computed as keys.length - channelIds.length, which treated "*" (a valid allow-all sentinel) the same as any other non-numeric, unresolvable key. The fix introduces a named constant DISCORD_CHANNEL_WILDCARD_KEY and rewrites the filter to explicitly exclude "*" from the unresolved tally, while continuing to count all other non-numeric, non-wildcard keys as unresolved — preserving existing behaviour for named channel keys.

Key changes:

  • src/discord/audit.ts: Added DISCORD_CHANNEL_WILDCARD_KEY = "*" and updated the unresolvedChannels computation to skip the wildcard key.
  • src/discord/audit.test.ts: Added a regression test verifying wildcard-only guild config yields channelIds = [] and unresolvedChannels = 0. The existing test for mixed numeric/named channels is unaffected and still asserts unresolvedChannels = 1 for a non-numeric named key ("general").

Confidence Score: 5/5

  • This PR is safe to merge — the change is minimal, well-scoped, and covered by regression tests.
  • The fix is surgical (two lines changed in the production path), introduces no new dependencies, does not affect any other code paths (allowlist matching, routing, permission probing), and is guarded by both a targeted new regression test and the unchanged existing test. The named constant avoids magic strings, and the filter logic is straightforward and correct.
  • No files require special attention.

Last reviewed commit: fdb121d

@thewilloftheshadow
Copy link
Copy Markdown
Member

Superseded by #33125 (includes the Discord wildcard audit fix). Please use that PR instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: discord Channel integration: discord size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Discord: false positive 'unresolvedChannels' warning when using '*' wildcard in guild channels

2 participants