anthropics / anthropics/claude-plugins-official

discord: cold-start channel-type mis-classification makes fetchAllowedChannel reject allowlisted channels

オープン
#3,466 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
Python
スター
36.3k
フォーク
4.1k
平均マージ
2日 14時間
マージ済み PR(30日)
539

説明

## Summary

In `external_plugins/discord/server.ts`, `fetchAllowedChannel` derives its allow/deny verdict from the **live-fetched channel type** before consulting the operator's access config. On a **cold MCP server start**, `client.channels.fetch()` can return a partial/cold channel object whose `.type` is momentarily mis-classified, so a guild channel the operator explicitly allowlisted in `access.groups` takes the wrong branch and throws `channel is not allowlisted` — **on the first call only**, succeeding on a later retry once the cache warms.

Most visible symptom: `download_attachment` rejecting a voice-message attachment from a correctly-allowlisted channel with a misleading "not allowlisted — add via /discord:access" error (the operator *has* added it).

## Current code

```ts
async function fetchAllowedChannel(id: string) {
const ch = await fetchTextChannel(id)
const access = loadAccess()
if (ch.type === ChannelType.DM) {
const userId = ch.recipientId ?? dmChannelUsers.get(id)
if (userId && access.allowFrom.includes(userId)) return ch
} else {
const key = ch.isThread() ? ch.parentId ?? ch.id : ch.id
if (key in access.groups) return ch
}
throw new Error(`channel ${id} is not allowlisted — add via /discord:access`)
}
```

## Proposed fix

Consult the access config first, independent of the live-fetched type:

```ts
const groupKey = ch.isThread() ? ch.parentId ?? ch.id : ch.id
if (id in access.groups || groupKey in access.groups) return ch
if (ch.type === ChannelType.DM) {
const userId = ch.recipientId ?? dmChannelUsers.get(id)
if (userId && access.allowFrom.includes(userId)) return ch
}
throw new Error(`channel ${id} is not allowlisted — add via /discord:access`)
```

The verdict becomes deterministic from config and no longer depends on fetch-cache warmth. **No access widening** — only ids already in `access.groups`/`allowFrom` pass; the unconfigured-id path still throws.

I opened this as a PR but the repo auto-closes external PRs, so filing as an issue. A ready-to-cherry-pick branch with this exact change + commit message is here: https://github.com/Wursthub/claude-plugins-official/tree/fix/discord-config-first-channel-access

🤖 Filed via Claude Code

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

調査の方向性

Start in external_plugins/discord/server.ts at fetchAllowedChannel, then inspect fetchTextChannel and the access configuration path. Verify that an allowlisted guild or thread channel passes on a cold fetch, while DM handling and unconfigured-id rejection remain unchanged; no test file is named in the issue.

索引モデルが issue の本文から書いたものです。

評価

技術スタック
typescript
領域
authorization, backend
issue の種類
バグ
難易度
2/5
見積もり時間
1〜3時間
活発さ
静か
明瞭さ
明確に書かれている
初心者へのやさしさ
45/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。