Skip to content

fix(admin): wire handleContentAuthors onto locals.emdash so the author filter stops 500ing (#1462)#1543

Open
marcusbellamyshaw-cell wants to merge 2 commits into
emdash-cms:mainfrom
marcusbellamyshaw-cell:fix/1462-wire-content-authors
Open

fix(admin): wire handleContentAuthors onto locals.emdash so the author filter stops 500ing (#1462)#1543
marcusbellamyshaw-cell wants to merge 2 commits into
emdash-cms:mainfrom
marcusbellamyshaw-cell:fix/1462-wire-content-authors

Conversation

@marcusbellamyshaw-cell

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes the admin author filter returning HTTP 500 NOT_CONFIGURED ("EmDash is not initialized") on GET /_emdash/api/content/{collection}/authors, for every collection.

locals.emdash is assembled as an object literal in middleware.ts. It wires every content handler — list, get, create, update, delete, all trash handlers, duplicate, publish, schedule, compare, translations, media, revisions — but handleContentAuthors was never added. So locals.emdash.handleContentAuthors is undefined on every request, and the route's guard returns 500 before the handler runs — which is exactly why it's consistent, affects every collection, and logs no error. The runtime method (emdash-runtime.ts), the standalone handler (api/handlers/content.ts), the EmDashHandlers type member, and the route itself all already exist — only this one wiring line was missing (it was overlooked when the author filter shipped in #1442).

Closes #1462

Type of change

  • Bug fix

Checklist

  • I have read CONTRIBUTING.md
  • pnpm typecheck passes — not run cleanly locally: branching off main left the installed workspace deps (@emdash-cms/plugin-types) out of sync, producing unrelated pre-existing errors. This change adds one property to an existing object literal and is type-safe — runtime.handleContentAuthors exists and matches the EmDashHandlers member signature.
  • pnpm lint passes (oxlint, 0 errors)
  • pnpm format has been run (oxfmt clean)
  • I have added/updated tests — see note. The handleContentAuthors handler itself is already covered by tests/integration/content/content-list-filters.test.ts; the omission was in the inline locals.emdash assembly, which is only observable through a full middleware boot.
  • User-visible strings wrapped for translation — n/a (server wiring; no admin UI strings)
  • I have added a changeset
  • New features link to an approved Discussion — n/a (bug fix)

AI-generated code disclosure

  • This PR includes AI-generated code — model/tool: Claude Opus 4.8 (Claude Code)

Notes

Why this slipped past CI: EmDashHandlers declares handleContentAuthors as required, yet the assembled object literal omitted it without a typecheck error — so locals.emdash's declared type is looser than the interface. A worthwhile follow-up (kept out of this PR to stay surgical) is to assemble locals.emdash through a typed () => EmDashHandlers factory or satisfies EmDashHandlers, so a missing handler fails pnpm typecheck — preventing the whole class of "added a handler + route but forgot to wire it onto locals.emdash" bug.

Full root-cause walkthrough in #1462.

…r filter stops 500ing

GET /_emdash/api/content/{collection}/authors reads emdash.handleContentAuthors, but the middleware that assembles the per-request locals.emdash object never included it — so it was undefined on every request and the route returned 500 NOT_CONFIGURED ("EmDash is not initialized") for every collection, while sibling content routes worked. The runtime method, standalone handler, type, and route all existed; only this one wiring line was missing.

Closes emdash-cms#1462

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Jun 19, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: dc5b38d

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

This PR includes changesets to release 16 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/do-demo-site Patch
@emdash-cms/do-solo-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

@ascorbic ascorbic left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks! Good spot

@pkg-pr-new

pkg-pr-new Bot commented Jun 19, 2026

Copy link
Copy Markdown

Open in StackBlitz

@emdash-cms/admin

npm i https://pkg.pr.new/@emdash-cms/admin@1543

@emdash-cms/auth

npm i https://pkg.pr.new/@emdash-cms/auth@1543

@emdash-cms/auth-atproto

npm i https://pkg.pr.new/@emdash-cms/auth-atproto@1543

@emdash-cms/blocks

npm i https://pkg.pr.new/@emdash-cms/blocks@1543

@emdash-cms/cloudflare

npm i https://pkg.pr.new/@emdash-cms/cloudflare@1543

@emdash-cms/contentful-to-portable-text

npm i https://pkg.pr.new/@emdash-cms/contentful-to-portable-text@1543

emdash

npm i https://pkg.pr.new/emdash@1543

create-emdash

npm i https://pkg.pr.new/create-emdash@1543

@emdash-cms/gutenberg-to-portable-text

npm i https://pkg.pr.new/@emdash-cms/gutenberg-to-portable-text@1543

@emdash-cms/plugin-cli

npm i https://pkg.pr.new/@emdash-cms/plugin-cli@1543

@emdash-cms/plugin-types

npm i https://pkg.pr.new/@emdash-cms/plugin-types@1543

@emdash-cms/registry-client

npm i https://pkg.pr.new/@emdash-cms/registry-client@1543

@emdash-cms/registry-lexicons

npm i https://pkg.pr.new/@emdash-cms/registry-lexicons@1543

@emdash-cms/sandbox-workerd

npm i https://pkg.pr.new/@emdash-cms/sandbox-workerd@1543

@emdash-cms/x402

npm i https://pkg.pr.new/@emdash-cms/x402@1543

@emdash-cms/plugin-ai-moderation

npm i https://pkg.pr.new/@emdash-cms/plugin-ai-moderation@1543

@emdash-cms/plugin-atproto

npm i https://pkg.pr.new/@emdash-cms/plugin-atproto@1543

@emdash-cms/plugin-audit-log

npm i https://pkg.pr.new/@emdash-cms/plugin-audit-log@1543

@emdash-cms/plugin-color

npm i https://pkg.pr.new/@emdash-cms/plugin-color@1543

@emdash-cms/plugin-embeds

npm i https://pkg.pr.new/@emdash-cms/plugin-embeds@1543

@emdash-cms/plugin-field-kit

npm i https://pkg.pr.new/@emdash-cms/plugin-field-kit@1543

@emdash-cms/plugin-forms

npm i https://pkg.pr.new/@emdash-cms/plugin-forms@1543

@emdash-cms/plugin-webhook-notifier

npm i https://pkg.pr.new/@emdash-cms/plugin-webhook-notifier@1543

commit: dc5b38d

…ing (emdash-cms#1462)

The middleware-prerender stub runtime listed every content handler except
handleContentAuthors, so once the middleware binds it the stub's missing
method makes `.bind` throw and `locals.emdash` never builds — failing the
"prerendered public runtime routes" test. Add the method to the stub
(matching the real runtime) and assert handleContentAuthors is wired, so
the emdash-cms#1462 regression is guarded directly.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@github-actions github-actions Bot added review/needs-rereview Author pushed changes since the last review size/S and removed size/XS review/needs-review No maintainer or bot review yet labels Jun 19, 2026
@marcusbellamyshaw-cell

Copy link
Copy Markdown
Contributor Author

Follow-up commit dc5b38de: CI's Tests job caught a regression my own change introduced — and it's a good catch worth being explicit about.

tests/unit/astro/middleware-prerender.test.ts builds a stub runtime that enumerated every content handler except handleContentAuthors. Once the middleware binds runtime.handleContentAuthors, the stub's missing method makes .bind throw, so locals.emdash never assembles and the "prerendered public runtime routes" test fails reading off undefined.

Fix: add handleContentAuthors to the stub (matching the real runtime, which has had the method all along) and assert typeof emdash.handleContentAuthors === "function" — so the wiring this PR adds is now guarded by a test directly, which also resolves the "added/updated tests" checklist item I'd left open. Typecheck passed on CI, confirming the earlier local typecheck note was just fork/main workspace drift, not a real issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/core cla: signed review/needs-rereview Author pushed changes since the last review size/S

Projects

None yet

2 participants