Skip to content

fix(block): require string keywords - #36

Merged
parisek merged 2 commits into
mainfrom
fix/block-keywords-item-type
Aug 10, 2026
Merged

fix(block): require string keywords#36
parisek merged 2 commits into
mainfrom
fix/block-keywords-item-type

Conversation

@parisek

@parisek parisek commented Aug 10, 2026

Copy link
Copy Markdown
Owner

From-Project

Found in sloneek while straightening definition-kit generator drift. keywords
was one of two block-config keys the generator was dropping (fixed upstream in
definition-kit v0.8.1); reviewing that fix surfaced that this package never
constrained the key's item type in the first place.

Why

"keywords": [1, 2, 3] passed both the validator and acf-lint --strict. WordPress
block metadata requires an array of strings — a numeric entry reaches the block
registry and is not usable as a search keyword. The schema declared type: ["null", "array"] and stopped there.

What

  • items: { "type": "string" } on keywords, in the extractor source and the
    generated schemas/block.schema.json.
  • A regression fixture (tests/fixtures/invalid/block-keywords-non-string/) that
    asserts the violation at /keywords/0. It was accepted before this change.

186 PHPUnit tests pass (1 expected skip), PHPStan clean, ADR check clean, and the
extractor output byte-matches the committed schema.

Deliberately not done

No minLength: 1. The package applies that constraint only where empty-string
stripping is already known to occur, which is not the case here. Adding it would be
a new rule, not the gap being closed.

Other untyped-array properties left alone. The same gap exists on
acf.hide_on_screen, cpt.capability_type, cpt.taxonomies, and a number of
field-schema arrays (choice arrays, default values, clone targets, palette colours,
icon tabs, post-type/taxonomy/status filters, bidirectional targets, relationship
filters, user roles, conditional-logic groups). Each needs real ACF serialization
evidence to type correctly — several accept mixed scalar shapes — so guessing an
item type would trade a permissive schema for a wrong one. Reported here rather
than fixed; worth its own issue.

@parisek parisek self-assigned this Aug 10, 2026
Leave other untyped array items unchanged because their serialized element shapes need targeted ACF evidence before narrowing the public schemas.
@parisek
parisek force-pushed the fix/block-keywords-item-type branch from 55eef2c to bf4e3f9 Compare August 10, 2026 11:24
@parisek
parisek marked this pull request as ready for review August 10, 2026 11:25
@parisek
parisek merged commit 7342274 into main Aug 10, 2026
4 checks passed
@parisek
parisek deleted the fix/block-keywords-item-type branch August 10, 2026 11:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant