Skip to content

fix: use REST-safe ability union schemas - #3081

Merged
chubes4 merged 2 commits into
mainfrom
fix-3067-rest-schema-types
Aug 9, 2026
Merged

fix: use REST-safe ability union schemas#3081
chubes4 merged 2 commits into
mainfrom
fix-3067-rest-schema-types

Conversation

@chubes4

@chubes4 chubes4 commented Aug 9, 2026

Copy link
Copy Markdown
Member

Summary

  • replace 123 array-valued Data Machine ability type unions with WordPress REST-supported anyOf branches while preserving every declared alternative
  • add registered-schema, _doing_it_wrong, representative content/nullable/multi-type, and Abilities REST response coverage
  • add a portable source/runtime smoke that audits all Data Machine ability schemas and validates the candidate plugin against active WordPress core

Root Cause

WordPress core supports array-valued type declarations, but rest_validate_value_from_schema() only collapses a multi-type schema when the runtime value matches one of its members. When no member matches, the unresolved array reaches the built-in type check and emits the misleading _doing_it_wrong notice before returning a validation error.

The production content signature comes from the core template/template-part REST schema in WP_REST_Templates_Controller, where content is object|string; list-valued payloads match neither type. Data Machine does not own or alter that core schema. This PR prevents the same failure mode in Data Machine's registered schemas by expressing unions with core's anyOf representation, which returns a normal no-matching-schema error without a developer notice.

Core paths checked:

  • wp-includes/rest-api.php: rest_handle_multi_type_schema(), rest_find_any_matching_schema(), rest_validate_value_from_schema()
  • wp-includes/abilities-api/class-wp-ability.php: input/output validation
  • wp-includes/rest-api/endpoints/class-wp-rest-abilities-v1-list-controller.php: schema exposure
  • wp-includes/rest-api/endpoints/class-wp-rest-abilities-v1-run-controller.php: REST execution validation
  • wp-includes/rest-api/endpoints/class-wp-rest-templates-controller.php: exact content signal

Validation

  • php tests/rest-schema-validation-smoke.php
  • wp --skip-plugins --skip-themes eval-file tests/rest-schema-validation-smoke.php
  • php tests/ability-provider-bootstrap-idempotency-smoke.php
  • php tests/lazy-runtime-ability-registration-smoke.php
  • php tests/content-format-abilities-smoke.php (44 assertions)
  • composer lint -- --report=summary
  • scoped Homeboy lint: 0 findings
  • scoped Homeboy PR audit: no introduced findings

Homeboy's local PHPUnit gate selected the suite but reported zero executed tests, matching the candidate-gate infrastructure failure documented in Homeboy #12006. The focused source and real-WordPress runtime smokes above executed and passed independently.

Fixes #3067

@chubes4
chubes4 merged commit f4d8c30 into main Aug 9, 2026
15 of 19 checks passed
@chubes4
chubes4 deleted the fix-3067-rest-schema-types branch August 9, 2026 17:57
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.

fix: use REST-supported types in ability schemas

1 participant