fix(member): AND --status against the whole --filter - #249
Conversation
`member list --filter <f> --status <s>` combined the two as `<f>+status:<s>` without parenthesizing the user filter. NQL binds `+` (AND) tighter than `,` (OR), so a filter containing a top-level OR was mis-grouped: `--filter 'label:vip,label:founders' --status paid` emitted `label:vip,label:founders+status:paid`, which parses as `label:vip OR (label:founders AND status:paid)` — the status constraint never applied to the first OR branch, returning members of the wrong status. AGENTS.md documents `--status` as composing with (AND) `--filter`. Parenthesize the user filter — `(<f>)+status:<s>` — the same defensive pattern already used in src/lib/client.ts. Also drop `status` from the params spread so it is not additionally sent as a standalone query param. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. WalkthroughThe member list command now wraps an existing comma-separated filter before appending Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: 🟡 Moderate · up to The filter fix is localized and the stated checks pass, but a reported duplicate Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This pull request fixes ghst member list filter composition so --status correctly ANDs against the entire user-supplied --filter expression (especially when the filter contains top-level ORs), aligning runtime behavior with the documented CLI contract.
Changes:
- Parenthesizes the user-provided
--filterbefore appending+status:<status>to preserve NQL operator grouping. - Prevents
statusfrom also being sent as a standalone query parameter (it is now solely encoded intofilter). - Adds a CLI-driven regression test asserting the exact outgoing
filterquery param and absence of a separatestatusparam.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/commands/member.ts |
Fixes NQL grouping by parenthesizing --filter before AND-ing --status, and removes leaked status query param. |
tests/commands-and-run.test.ts |
Adds regression coverage to ensure (filter)+status:… is sent and no standalone status param is included. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Problem
member list --filter <f> --status <s>combines the two into a single NQL filter, but does not parenthesize the user-supplied filter:NQL binds
+(AND) more tightly than,(OR), so any user filter containing a top-level OR is mis-grouped. For example:emits the filter
label:vip,label:founders+status:paid, which NQL parses as:So the
--status paidconstraint is silently not applied to thelabel:vipbranch — members with the wrong status are returned.AGENTS.mddocuments--statusas composing with (AND-ing)--filter.A second, minor issue:
statusalso leaked through the...parsed.dataspread as a standalonestatus=query param (harmless — Ghost ignores it — but unintended).Fix
Parenthesize the user filter so the status ANDs against the whole thing:
`(${parsed.data.filter})+status:${parsed.data.status}`This is the same defensive-parenthesization pattern already used in
src/lib/client.tsfor the comment-thread filter. Also dropstatusfrom the params passed tolistMembers, since it is folded into the filter.Single-clause filters (no top-level OR) are unaffected —
label:vip+status:paidand(label:vip)+status:paidare equivalent — which is why this went unnoticed.Tests
Added a
member listtest that drives the CLI and asserts the outgoingfilterquery param is(label:vip,label:founders)+status:paidand that no standalonestatusparam is sent. It fails onmain(emits the unparenthesized form) and passes with this change.lint/format:check/typecheck/ fulltest/buildall pass.🤖 Generated with Claude Code