fix(core): split comma-separated tags in parse_tags#911
Conversation
Bug #7 (integration bug hunt): `bm tool write-note --tags "a,b"` stored one mangled tag "a,b" instead of splitting into ["a","b"], diverging from the MCP write_note convention. Typer collects a single `--tags "a,b"` into the one-element list ['a,b'], and parse_tags() only split a bare string on commas, leaving list elements verbatim. parse_tags() now flattens by splitting each list element on commas, so "a,b", ["a,b"], and ["a","b"] all converge to ["a","b"]. The search_notes 'tags' coercer is intentionally left unchanged (tracked separately as #910). Tests come from the integration bug hunt: a CLI/MCP convergence test under test-int/bughunt_fixes/ plus unit parametrize cases in tests/utils/test_parse_tags.py. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: phernandez <paul@basicmachines.co>
|
Claude finished @phernandez's task in 1m 35s —— View job PR Review: fix(core): split comma-separated tags in parse_tagsTasks:
SummaryThis is a clean, minimal bug fix. The root cause is well-diagnosed: Typer wraps a single Team ChecklistCode Quality & Standards
Testing & Documentation
Basic Memory Architecture
Security & Performance
FindingsNo blocking issues. Three minor observations: 1. Defensive for tag in str(raw).split(",")The type annotation is 2. Pre-existing duplicate
3. New This is a new directory without precedent in ConclusionThe fix is correct and well-scoped. The |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: dfef6f4464
ℹ️ 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".
| return [ | ||
| tag.strip().lstrip("#") | ||
| for raw in tags | ||
| for tag in str(raw).split(",") |
There was a problem hiding this comment.
Skip null list entries before stringifying
When frontmatter or a JSON tag array contains a null entry, e.g. tags: [alpha, null], normalize_frontmatter_metadata() preserves that None and passes the list into parse_tags(). The old list branch skipped falsy entries, but this change stringifies each raw item before filtering, so None becomes the literal tag "None" and can be indexed or written back as a real tag. Filter raw/None before splitting so comma-separated strings are still flattened without reviving previously ignored null tag values.
Useful? React with 👍 / 👎.
Codex review: parse_tags must not revive a null list entry (YAML 'tags: [alpha, null]') as the literal tag 'None' — skip None before stringifying. Also fix the comma-split integration test's frontmatter assertion to use splitlines() so it passes on Windows CRLF. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: phernandez <paul@basicmachines.co>
|
Claude finished @phernandez's task in 1m 35s —— View job PR Review: fix(core): split comma-separated tags in parse_tagsTasks:
SummaryThis is a well-scoped, clean bug fix. The root cause (Typer collecting Team ChecklistCode Quality & Standards
Testing & Documentation
Basic Memory Architecture
Security & Performance
Compatibility
FindingsNo blocking issues. Three minor observations for awareness: 1. Type annotation doesn't reflect def parse_tags(tags: Union[List[str], str, None]) -> List[str]:The function now explicitly handles 2. Pre-existing inline
3. New This is a new directory pattern without precedent in ConclusionThe fix is correct and the |
Summary
bm tool write-note --tags "a,b"stored a single mangled taga,binstead of splitting into["a", "b"], diverging from the MCPwrite_note(tags="a,b")convention. Typer collects a single--tags "a,b"value into the one-element list["a,b"], andparse_tags()only split a bare string on commas — list elements were returned verbatim, so the comma survived as part of a single literal tag.parse_tags()(src/basic_memory/utils.py) now flattens by splitting each list element on commas before stripping#/whitespace, so"a,b",["a,b"], and["a", "b"]all converge to["a", "b"]. This is the single source of truth, so CLI--tags "a,b", CLI--tags a --tags b, and the MCP comma/list/JSON forms now agree.The
search_notestagscoercer is intentionally left unchanged — its comma behavior is tracked separately as #910.Bugs fixed
write-note --tags "a,b"does not split comma-separated tags (diverges from MCPwrite_note).Testing
uv run pytest test-int/bughunt_fixes/test_parse_tags_comma_split_integration.py -q --no-cov— 2 passed (CLI/MCP convergence + MCP baseline; the bug-hunt integration test that failed on main now passes).uv run pytest tests/utils/test_parse_tags.py -q --no-cov— 23 passed (added list-comma parametrize cases).uv run pytest tests/mcp/test_tool_write_note.py test-int/cli/ tests/mcp/test_tool_contracts.py tests/mcp/test_tool_telemetry.py -q --no-cov— 116 passed (no regressions; tool signatures unchanged).uv run ruff check . --fix,uv run ruff format .,uv run ty check src tests test-int— all clean for scoped files.Risk
Low. Behavior change is confined to the
parse_tags()list branch and only affects list elements that themselves contain commas — previously these produced an invalid single-literal tag. No existing test relied on commas being preserved inside a list element. The search-notes coercer is untouched.🤖 Generated with Claude Code