fix: split comma-separated tags in search_notes tags parameter#918
fix: split comma-separated tags in search_notes tags parameter#918jagadeeswara-ks wants to merge 5 commits into
Conversation
The `tags=` parameter coerced a bare comma string like "alpha,beta" into the single literal tag ["alpha,beta"] (matching nothing), while the `tag:alpha,beta` query shorthand and write_note both split on commas. Swap the BeforeValidator from coerce_list to the existing parse_tags so all three paths agree. Adds an integration regression test asserting the `tags=` parameter and the `tag:` query shorthand return the same results for a comma string. Fixes basicmachines-co#910 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: K Jagadeeswara Reddy <social@jagadeeswar.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4560638b8c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| # Use parse_tags (not coerce_list) so a bare comma string like "alpha,beta" | ||
| # splits into ["alpha", "beta"], matching the `tag:` query shorthand and | ||
| # write_note's tag convention. See #910. | ||
| BeforeValidator(parse_tags), |
There was a problem hiding this comment.
Reject non-list tag values instead of stringifying them
When tags receives an invalid JSON value such as an object or number, parse_tags falls through to parse_tags(str(tags)), so the MCP argument validator now accepts malformed filters as a literal tag instead of failing validation. The previous coerce_list path left non-string/non-list values for Pydantic to reject, so bad client payloads surfaced immediately; now they become successful searches with confusing no-result behavior. Use a search-specific parser that only accepts str, list[str], or None before splitting comma strings.
Useful? React with 👍 / 👎.
Integration regression test for #910: the tags= parameter and the tag:alpha,beta query shorthand must return the same results for the same comma string. Cherry-picked from #918. The validator swap itself (coerce_list -> parse_tags) landed separately via #932; this carries the remaining test-only piece with original authorship. Signed-off-by: K Jagadeeswara Reddy <social@jagadeeswar.com>
Integration regression test for #910: the tags= parameter and the tag:alpha,beta query shorthand must return the same results for the same comma string. Cherry-picked from #918. The validator swap itself (coerce_list -> parse_tags) landed separately via #932; this carries the remaining test-only piece with original authorship. Signed-off-by: K Jagadeeswara Reddy <social@jagadeeswar.com>
|
Closing this one out — with thanks, and with your work landed. You had the correct fix for #910 first; our automation raced you with a duplicate (#932), which was our process failure, not a problem with this PR. To make sure the contribution counted, we carried your commit forward in #943 and rebase-merged it, so it now sits on main with your authorship intact: 44ecec2 — The validator change itself reached main via #932, and follow-ups #941 hardened the same boundary further. Your scoping note about Hope to see more PRs from you — and next time the bots will check for an existing PR before touching an issue. |
Fixes #910
search_notes(tags="alpha,beta")returned zero results because thetagsparameter coerced the bare comma string into the single literal tag["alpha,beta"], while thetag:alpha,betaquery shorthand (andwrite_note's tag convention) split on commas. Within one tool, comma-string tags behaved two different ways.This swaps the
tagsBeforeValidatorfromcoerce_listto the existingparse_tags, which already handles lists, JSON-array strings, and bare comma strings consistently (and is the same helperwrite_noteand the entity parser use). This preserves the JSON-array-string handlingcoerce_listprovided while adding comma-splitting, so thetags=parameter now matches thetag:shorthand.Scope is kept to
tags. The relatednote_types/entity_types/categoriesfilters still usecoerce_list; applying comma-splitting there is a separate decision (andparse_tags'#-stripping is tag-specific), so I left them untouched — happy to follow up if you'd like consistent splitting on those too.Added an integration regression test asserting the
tags=parameter and thetag:shorthand return the same results for the same comma string. A unit test at thesearch_noteslevel isn't included on purpose: theBeforeValidatordoesn't run on direct Python calls (only through the validated MCP path), so the integration level is where this is meaningfully covered.parse_tagsitself is already exhaustively unit-tested.Verified locally: the full search unit + integration suites (64 passing),
ruff, andtyall green.🤖 AI-assisted (Claude Code), human-reviewed.
Reviewed SHA:
af64adadcdb1b5e0a422ff0355485a66869ee16dVerdict:
needs_humanStatus:
failure- BM Bossbot review did not finishSummary:
BM Bossbot intentionally did not run Codex because this PR was not opened by an owner, member, or collaborator.
Blocking findings:
Non-blocking findings: