fix: auto-allow the group created by /new chat - #185
Open
loml13 wants to merge 1 commit into
Open
Conversation
The v2 access policy is fail-closed: a chat_id absent from `allowedChats` is denied with reason `denied-chat` (logged as `skip-not-allowed-user`). When `/new chat` spins up a fresh group, the new chat_id was never added to the allowlist, so the bot wouldn't actually engage in the very group it just created — the user had to run `/invite group` from inside it to make it usable. Persist the new chat_id into `allowedChats` (idempotent) right after the group is created, reusing the existing `saveAccessConfig` path so the write goes through the same config-file lock and in-memory refresh as `/invite`. Best-effort: the group already exists, so a persistence failure only logs and leaves `/invite group` as the manual fallback rather than failing the command. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
/new chatspins up a fresh Feishu/Lark group, invites the requester, inheritsthe cwd, and posts a welcome message — but the new
chat_idis never added topreferences.access.allowedChats.The v2 access policy is fail-closed:
canUseGrouponly lets a groupthrough when the sender is the owner/an admin, or the
chat_idis inallowedChats. So for anyone who isn't the owner/admin, the bot won't engagein the very group it just created (
skip-not-allowed-user, reasondenied-chat) — at best it replies with a "group not allowed" hint tellingyou to run
/invite group, at worst (non-mention messages) it just dropsthem. Either way, it builds a room it then refuses to actually use. The only
recovery today is to run
/invite groupfrom inside the new group.Repro
allowedUsers, notadmins)./new chat demo.skip-not-allowed-user(reason
denied-chat) — because the newchat_idwas never whitelisted.Change
After the group is created (and the cwd inherited), persist the new
chat_idinto
allowedChats, reusing the existingsaveAccessConfigpath so the writegoes through the same config-file lock and in-memory refresh as
/invite. Theadd is idempotent (set-based) and best-effort: the group already exists, so
a persistence failure only logs a warning and leaves
/invite groupas themanual fallback rather than failing the command. The log line records only the
last 6 chars of the
chat_id.Compatibility
No behavior change to any existing flow. This only writes a
chat_idthe botjust created into the allowlist — exactly what the user would otherwise have to
do by hand with
/invite group. Existing groups and access lists areuntouched.
Testing
pnpm typecheck— clean.pnpm test— full suite green (adds 2 tests).tests/integration/commands/new-chat-auto-allow.test.ts:/new chatpersists the createdchat_idintoallowedChats.chat_idis already allowed (no duplicate entry).🤖 Generated with Claude Code