Repository navigation
Fix forms embed definition envelope handling - #983
Conversation
🦋 Changeset detectedLatest commit: 16cc134 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
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 |
|
All contributors have signed the CLA ✍️ ✅ |
|
I have read the CLA Document and I hereby sign the CLA |
|
/review |
|
Good. The Now let me do a quick sanity check — does But there's a subtle issue: what if the API does not return the envelope (e.g., during migration or future changes)? The new code would silently return null without logging. The old code would have had Overall this is a small, focused, well-tested bugfix:
The PR is well-scoped, has good test coverage, and correctly fixes a real bug. I'll respond with LGTM. LGTM! |
@emdash-cms/admin
@emdash-cms/auth
@emdash-cms/blocks
@emdash-cms/cloudflare
emdash
create-emdash
@emdash-cms/gutenberg-to-portable-text
@emdash-cms/x402
@emdash-cms/plugin-ai-moderation
@emdash-cms/plugin-atproto
@emdash-cms/plugin-audit-log
@emdash-cms/plugin-color
@emdash-cms/plugin-embeds
@emdash-cms/plugin-forms
@emdash-cms/plugin-webhook-notifier
commit: |
There was a problem hiding this comment.
Pull request overview
This PR fixes embedded forms rendered by @emdash-cms/plugin-forms by correctly unwrapping the core plugin API success envelope ({ data: ... }) when fetching public form definitions from the Astro embed component.
Changes:
- Added a small forms-owned response parser (
parsePublicFormDefinitionResponse) that reusesemdash/plugin-utils’parseApiResponse()to unwrap{ data: ... }. - Updated
FormEmbed.astroto use the new parser (and removed the incorrect “treat entire JSON body as the definition” behavior). - Added Vitest coverage for the new parsing behavior and wired the forms plugin into workspace unit tests.
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
packages/plugins/forms/src/astro/FormEmbed.astro |
Uses the new parser so embeds read the { data: ... } envelope correctly. |
packages/plugins/forms/src/public-definition.ts |
Introduces a focused parser for public definition responses, including active-form filtering. |
packages/plugins/forms/tests/public-definition.test.ts |
Adds unit tests validating envelope unwrapping and null behavior for inactive/missing/failed cases. |
packages/plugins/forms/vitest.config.ts |
Adds Vitest config consistent with other plugins’ test setups. |
packages/plugins/forms/package.json |
Adds vitest devDependency and a test script for the forms plugin package. |
package.json |
Includes @emdash-cms/plugin-forms in the test:unit filter set. |
.changeset/forms-embed-definition-envelope.md |
Adds a patch changeset describing the user-visible bug fix. |
pnpm-lock.yaml |
Lockfile update to reflect the new vitest devDependency for the forms plugin. |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
What does this PR do?
Fixes embedded forms rendered by
@emdash-cms/plugin-formsso the Astro block component reads the standard plugin API success envelope.The public form definition route is exposed through the core plugin API route, which returns successful responses as
{ data: ... }.FormEmbed.astropreviously treated the whole JSON body as the form definition, soform.statuswas undefined and the form silently did not render.This PR moves public definition response handling into a small forms-owned parser that reuses
emdash/plugin-utils' existingparseApiResponse()envelope unwrapping, then uses that parser from the Astro embed component.No related issue.
Type of change
Checklist
pnpm typecheckpassespnpm lintpassespnpm testpasses (or targeted tests for my change)pnpm formathas been runmessages.pochanges except in translation PRs — a workflow extracts catalogs on merge tomain.AI-generated code disclosure
Screenshots / test output
Validated locally on Windows:
pnpm buildpassespnpm typecheckpassespnpm lintpasses with 0 errorspnpm --filter @emdash-cms/plugin-forms testpassespnpm --filter @emdash-cms/plugin-forms typecheckpassesgit diff --checkpassesNotes:
CI=true pnpm test:unitcurrently fails locally on Windows before the forms test run because@emdash-cms/marketplace'spublish-e2e.test.tsinvokes the built CLI and hits Node's ESM loader error for ad:absolute Windows path. This appears unrelated to this forms change.pnpm format:checkreports repo-wide formatting issues on Windows, while targeted Prettier checks for this PR's changed files pass.