Skip to content

Conversation

@sirreal
Copy link
Member

@sirreal sirreal commented Sep 23, 2025

What?

Disallow extra properties in the supports.colors block.json schema.
Fix existing schema errors (tests had some apiVersion: 2, only 3 is allowed now).

See #71800.

Why?

This fixes and helps prevent schema issues.

This is merged to #71851 where JSON schema checking is added to CI.

Testing Instructions

See tests pass on #71851, specifically JSON schema checks: https://github.com/WordPress/gutenberg/actions/runs/17954394785/job/51061796157

@sirreal sirreal force-pushed the fix/json-schema-invalidations branch from 2e95615 to 32c18ad Compare September 23, 2025 17:20
@sirreal sirreal marked this pull request as ready for review September 23, 2025 17:47
@github-actions
Copy link

github-actions bot commented Sep 23, 2025

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: sirreal <jonsurrell@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions
Copy link

github-actions bot commented Sep 23, 2025

Flaky tests detected in 8de8923.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/17974568163
📝 Reported issues:

@t-hamano
Copy link
Contributor

t-hamano commented Sep 24, 2025

Thanks for the PR!

Disallow extra properties in the supports.colors block.json schema.

I'm not sure if we should do this or not - block.json is just a JSON file, and consumers may have extended the core support or added their own.

{
	"$schema": "https://schemas.wp.org/trunk/block.json",
	"apiVersion": 3,
	"name": "myplugin/myblock",
	"title": "My Block",
	"supports": {
		"color": {
			"text": true,
			"myPlugin": {
				"myPluginColorControl": true
			}
		},
		"myPlugin": {
			"myPluginCustomControl": true
	}
}

In this PR, how about just updating the API version and doing the schema-based check in #71851?

There is also a discussion on how to add custom support: #71012

@sirreal
Copy link
Member Author

sirreal commented Sep 24, 2025

I removed the other changes and just updated the apiVersion in the schemas.

I'm not sure if we should do this or not - block.json is just a JSON file, and consumers may have extended the core support or added their own.

There is also a discussion on how to add custom support: #71012

Allowing arbitrary extra properties weakens the schema. It would be nice if they were at least required to follow a prefix like customMyProperty. Then we could allow them without weakening the schema by allowing arbitrary keys which is why issues like #71800 happen.

Copy link
Contributor

@t-hamano t-hamano left a comment

Choose a reason for hiding this comment

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

LGTM! Since this PR ended up being just a PR to update the apiVersion, can we update the PR title and description before merging?

Allowing arbitrary extra properties weakens the schema. It would be nice if they were at least required to follow a prefix like customMyProperty. Then we could allow them without weakening the schema by allowing arbitrary keys which is why issues like #71800 happen.

This is understandable, and we may be able to consider in a follow-up what keys should be allowed or not.

@sirreal sirreal changed the title JSON Schema: Improve and fix validation JSON Schema: Update block.json apiVersion to 3 Sep 24, 2025
@sirreal sirreal merged commit dcb9977 into trunk Sep 24, 2025
77 of 78 checks passed
@sirreal sirreal deleted the fix/json-schema-invalidations branch September 24, 2025 13:43
@github-actions github-actions bot added this to the Gutenberg 21.8 milestone Sep 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Type] Code Quality Issues or PRs that relate to code quality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants