Skip to content

fix(document-api): handle JSON-encoded tags in SDT query operations#3717

Open
mattConnHarbour wants to merge 2 commits into
mainfrom
matthew/sd-3428-fix-sdt-tag-query-mismatch
Open

fix(document-api): handle JSON-encoded tags in SDT query operations#3717
mattConnHarbour wants to merge 2 commits into
mainfrom
matthew/sd-3428-fix-sdt-tag-query-mismatch

Conversation

@mattConnHarbour

Copy link
Copy Markdown
Contributor

Summary

  • Add matchesTag() helper to handle both plain string and JSON-encoded tag formats
  • Fix selectByTag and list queries to find SDTs created via the StructuredContent extension
  • The extension stores tags as {"group":"tag"} while Document API stores plain "tag"

Test plan

  • Create SDT via Document API with a tag
  • Create SDT via editor command with same tag
  • Verify selectByTag returns both SDTs
  • Verify list({ tag: '...' }) returns both SDTs

Fixes SD-3428

🤖 Generated with Claude Code

@mattConnHarbour mattConnHarbour requested a review from a team as a code owner June 11, 2026 20:32
@linear-code

linear-code Bot commented Jun 11, 2026

Copy link
Copy Markdown

SD-3428

The StructuredContent extension stores tags as JSON (e.g., `{"group":"tag"}`),
while the Document API stores them as plain strings. This caused selectByTag
and list queries to fail when searching for SDTs created via the editor.

Add matchesTag() helper that handles both formats, checking for direct string
match first, then parsing JSON to check the `group` property as fallback.

SD-3428

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@mattConnHarbour mattConnHarbour force-pushed the matthew/sd-3428-fix-sdt-tag-query-mismatch branch from 960f98b to affabfd Compare June 11, 2026 20:36
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Address galley review findings:
- Add 7 regression tests for JSON-encoded tag matching
- Refactor matchesTag() to use canonical getGroup() helper from tagUtils.js
  to avoid duplicating JSON decode logic

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants