Skip to content

jhb-dev/payload-rest-blocks-missing-blocktype

Repository files navigation

payload-rest-blocks-missing-blocktype

Minimal reproduction of a Payload CMS v3 bug:

Blocks without a matching blockType are silently dropped instead of rejected with a validation error.

When you POST a document with a blocks field via the REST API and a block row has no blockType (or an unknown one — e.g. you accidentally send blockName instead of blockType), Payload returns 201 Created and silently discards the block. No validation error is raised, producing broken pages with empty content. When the same block has a valid blockType but is missing a required field, Payload correctly returns 400 — so the behavior is inconsistent.

See ISSUE.md for the full write-up, root-cause analysis, and exact reproduction steps.

Running

pnpm install
pnpm dev

Then, with the dev server running:

# Bug: block with no blockType -> 201 Created, block silently dropped
curl -i -X POST http://localhost:3000/api/pages \
  -H "Content-Type: application/json" \
  -d '{"title":"Wholesale","layout":[{"id":"block-wholesale-hero","blockName":"hero-alpha"}]}'

# Control: valid blockType but missing required field -> 400 ValidationError
curl -i -X POST http://localhost:3000/api/pages \
  -H "Content-Type: application/json" \
  -d '{"title":"Retail","layout":[{"id":"block-retail-hero","blockType":"hero"}]}'

A default admin user demo@payloadcms.com / demo is seeded for inspecting the broken docs at /admin.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors