Skip to content

fix(core): include term description for flat taxonomies in getTaxonomyTerms()#1420

Open
swissky wants to merge 1 commit into
emdash-cms:mainfrom
swissky:fix/flat-taxonomy-term-description
Open

fix(core): include term description for flat taxonomies in getTaxonomyTerms()#1420
swissky wants to merge 1 commit into
emdash-cms:mainfrom
swissky:fix/flat-taxonomy-term-description

Conversation

@swissky

@swissky swissky commented Jun 12, 2026

Copy link
Copy Markdown

What does this PR do?

getTaxonomyTerms() already fetches the data column (selectAll()), but the non-hierarchical branch dropped it when mapping rows to TaxonomyTerm — only hierarchical taxonomies (via buildTree) parsed description out of it. Descriptions set in the admin UI were silently undefined for flat taxonomies.

This adds the same one-line mapping the hierarchical path uses, plus a unit test covering both kinds of taxonomies (the flat case fails without the fix).

Context: we attach knowledge-graph links (e.g. wikidata:Q380274) to term descriptions and render them as sameAs in JSON-LD; flat taxonomies (tags, treatments) lost them.

Closes #1419

Type of change

  • Bug fix
  • Feature (requires maintainer-approved Discussion)
  • Refactor (no behavior change)
  • Translation
  • Documentation
  • Performance improvement
  • Tests
  • Chore (dependencies, CI, tooling)

Checklist

  • I have read CONTRIBUTING.md
  • pnpm typecheck passes (packages/core; @emdash-cms/admin/marketplace builds fail on my machine on unrelated tooling, untouched by this PR)
  • pnpm lint passes (lint:quick clean)
  • pnpm test passes (targeted: packages/core/tests/unit/taxonomies/ — 4 files, 48 tests green; new test red without the fix)
  • pnpm format has been run
  • I have added/updated tests for my changes (if applicable)
  • User-visible strings in the admin UI are wrapped for translation (n/a — no UI strings)
  • I have added a changeset (emdash patch)
  • New features link to an approved Discussion (n/a — bug fix)

AI-generated code disclosure

  • This PR includes AI-generated code — model/tool: Cursor + Fable 5 (reviewed and verified by a human before submission)

Screenshots / test output

RUN  v4.1.5 packages/core
✓ tests/unit/taxonomies/get-taxonomy-terms.test.ts (2 tests) — with fix
✗ 1 failed (flat-taxonomy description) — without fix (TDD check)
Test Files  4 passed (4)   Tests  48 passed (48)   # full unit/taxonomies folder

…yTerms()

The non-hierarchical branch dropped the already-fetched data column when
mapping rows to TaxonomyTerm; only buildTree (hierarchical) parsed it.

Closes emdash-cms#1419
@github-actions

github-actions Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@github-actions github-actions Bot added review/needs-review No maintainer or bot review yet area/core size/M labels Jun 12, 2026
@changeset-bot

changeset-bot Bot commented Jun 12, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 5a4231a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 14 packages
Name Type
emdash Patch
@emdash-cms/cloudflare Patch
@emdash-cms/sandbox-workerd Patch
@emdash-cms/fixture-perf-site Patch
@emdash-cms/perf-demo-site Patch
@emdash-cms/cache-demo-site Patch
@emdash-cms/admin Patch
@emdash-cms/auth Patch
@emdash-cms/blocks Patch
@emdash-cms/gutenberg-to-portable-text Patch
@emdash-cms/x402 Patch
create-emdash Patch
@emdash-cms/auth-atproto Patch
@emdash-cms/plugin-embeds Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@swissky

swissky commented Jun 12, 2026

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

github-actions Bot added a commit that referenced this pull request Jun 12, 2026

@emdashbot emdashbot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a clean, well-scoped bug fix. The approach is sound: getTaxonomyTerms() already fetched the data column, and the PR simply adds the same description extraction that the hierarchical branch (buildTree) and getTerm already used. The flat-taxonomy branch was the only place silently dropping it.

I checked:

  • The one-line fix matches the existing pattern elsewhere in the module.
  • The new unit test covers both flat and hierarchical taxonomies (the PR author verified the flat case fails without the fix).
  • Locale filtering is unchanged and correct.
  • A changeset is present and well-written.
  • No SQL, auth, API route, or admin UI changes, so AGENTS.md conventions around those areas don't apply.

One suggestion: getEntryTerms in the same module also selects data via selectAll("taxonomies") but drops description when mapping rows. It's the exact same bug pattern, so it's worth a quick follow-up if entry-level term rendering also needs descriptions.

@github-actions github-actions Bot added review/awaiting-author Reviewed; waiting on the author to respond and removed review/needs-review No maintainer or bot review yet labels Jun 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/core cla: signed review/awaiting-author Reviewed; waiting on the author to respond size/M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

getTaxonomyTerms() drops term description for flat (non-hierarchical) taxonomies

1 participant