Skip to content

Conversation

@jorgefilipecosta
Copy link
Member

We are currently using draft-04 of json schema on the validator, but the schemas we are using required at least the 2020 version because of having examples and defaults.

Testing

Currently the ajv validation only happens for the output of client side abiltiies not the server ones so this issue is hidden but it will be exposed when hybrid abilities are implemented.

Paste the following code on the browser console:

const envInfoAbility = await wp.abilities.getAbility(
	'core/get-environment-info'
);
const envInfoResult = await wp.abilities.executeAbility(
	'core/get-environment-info'
);
await wp.abilities.registerAbility( {
	...envInfoAbility,
	name: 'core/get-environment-info-client',
	callback: () => envInfoResult,
} );
await wp.abilities.executeAbility( 'core/get-environment-info-client' );

It registers a core/get-environment-info-client client ability exactly the same as the server one.
Verify things work well.
Paste the same code on trunk and verify there is this error and the ability does not works:

Schema compilation error: Error: strict mode: unknown keyword: "examples"
    at checkStrictMode (util.js:174:1)
    at checkUnknownRules (util.js:32:1)
    at alwaysValidSchema (util.js:19:1)
    at properties.js:23:1
    at Array.filter (<anonymous>)
    at Object.code (properties.js:23:1)
    at keywordCode (index.js:464:1)
    at index.js:222:1
    at CodeGen.code (index.js:439:1)
    at CodeGen.block (index.js:568:1)

@github-actions
Copy link

github-actions bot commented Nov 12, 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: jorgefilipecosta <[email protected]>
Co-authored-by: justlevine <[email protected]>
Co-authored-by: gziolo <[email protected]>

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

@codecov
Copy link

codecov bot commented Nov 12, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.31%. Comparing base (272d306) to head (c55e36d).
⚠️ Report is 1 commits behind head on trunk.

Additional details and impacted files
@@             Coverage Diff              @@
##              trunk     #142      +/-   ##
============================================
- Coverage     80.39%   76.31%   -4.08%     
  Complexity      178      178              
============================================
  Files            20       13       -7     
  Lines          1474     1140     -334     
  Branches        120        0     -120     
============================================
- Hits           1185      870     -315     
+ Misses          289      270      -19     
Flag Coverage Δ
javascript ?
unit 76.31% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@justlevine
Copy link
Contributor

justlevine commented Nov 12, 2025

(Related discussion re JSON draft-4 #109 (review) - for the cross-link)

@gziolo
Copy link
Member

gziolo commented Nov 12, 2025

It looks like examples property is ignored by the custom WordPress validator for JSON schema. I couldn't find any usage in WP core that would use that property. In effect, I would recommend removing that line of code rather than trying to use the latest JSON schema without aligning with what is supported on the server.

The other aspect is that we could offer in the future to opt-in for the most recent JSON schema by explicitly defining the version. I don't think we even do it now, and set:

'$schema'    => 'http://json-schema.org/draft-04/schema#',

That would be helpful to be explicit.

@jorgefilipecosta
Copy link
Member Author

Closed in favor of #144 and WordPress/wordpress-develop#10510.

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.

4 participants