Skip to content

Utils: Preserve omitted ability input#775

Merged
dkotter merged 1 commit into
developfrom
codex/run-ability-omitted-input
Jun 29, 2026
Merged

Utils: Preserve omitted ability input#775
dkotter merged 1 commit into
developfrom
codex/run-ability-omitted-input

Conversation

@jorgefilipecosta

@jorgefilipecosta jorgefilipecosta commented Jun 25, 2026

Copy link
Copy Markdown
Member

What?

  • Preserves omitted runAbility() input as undefined instead of normalizing it to null.
  • Omits REST fallback input payloads when the caller does not provide input.
  • Keeps explicitly provided empty-object input as request input.

Why?

Some abilities use an object schema with a default empty object for empty collection/query mode. Passing null prevents the abilities client from applying that schema default and can make runAbility( 'core/users' ) fail where executeAbility( 'core/users' ) succeeds.

Core users is at #774.

How?

  • Passes the optional runAbility() input argument through to the client abilities API without coercing omitted input to null.
  • Builds REST fallback requests without a data.input payload when input is omitted.
  • Preserves explicitly provided input values, including {}, when building REST fallback requests.

Use of AI Tools

AI assistance: Yes
Tool(s): Codex
Model(s): GPT-5
Used for: Implementation assistance, manual test planning, and PR description updates. Final changes were reviewed and verified locally.

Testing Instructions

Manual testing:

  1. Use the Playground preview or a local environment with this PR and the core/users ability from Add core/read-users ability #774 available.
  2. Open a WordPress admin page where the abilities client modules are loaded, such as the post editor after enabling one AI experiment.
  3. In the browser console, run const { ready } = await import( '@wordpress/core-abilities' ); await ready; const { executeAbility } = await import( '@wordpress/abilities' ); await executeAbility( 'core/users' );.
  4. Confirm the call succeeds and returns the users result without passing an input argument.
  5. In the same browser console, run await wp.apiFetch( { path: '/wp-abilities/v1/abilities/core/users/run', method: 'POST' } );.
  6. Confirm the REST fallback shape with no data.input also succeeds.
  7. Run await wp.apiFetch( { path: '/wp-abilities/v1/abilities/core/users/run', method: 'POST', data: { input: {} } } );.
  8. Confirm the explicit empty-object input still succeeds, verifying that omitted input and {} remain distinct.

Automated testing:

  • npm run lint:js -- src/utils/run-ability.ts
  • npm run typecheck

Screenshots or screencast

Not applicable; this is a utility behavior change without UI changes.

Changelog Entry

Fixed - Preserve omitted runAbility() input so ability schema defaults can apply when abilities are invoked without input.

Open WordPress Playground Preview

@github-actions

github-actions Bot commented Jun 25, 2026

Copy link
Copy Markdown

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 <jorgefilipecosta@git.wordpress.org>
Co-authored-by: dkotter <dkotter@git.wordpress.org>
Co-authored-by: gziolo <gziolo@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
Copy Markdown

✅ WordPress Plugin Check Report

✅ Status: Passed

📊 Report

All checks passed! No errors or warnings found.


🤖 Generated by WordPress Plugin Check Action • Learn more about Plugin Check

@codecov

codecov Bot commented Jun 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.48%. Comparing base (ea79289) to head (8d34d98).
⚠️ Report is 3 commits behind head on develop.

Additional details and impacted files
@@            Coverage Diff             @@
##             develop     #775   +/-   ##
==========================================
  Coverage      76.48%   76.48%           
  Complexity      1869     1869           
==========================================
  Files             89       89           
  Lines           7990     7990           
==========================================
  Hits            6111     6111           
  Misses          1879     1879           
Flag Coverage Δ
unit 76.48% <ø> (ø)

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

☔ View full report in Codecov by Harness.
📢 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.

Comment thread tests/unit/run-ability.test.ts Outdated
gziolo
gziolo previously approved these changes Jun 25, 2026

@gziolo gziolo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Approved. Verified locally: install, build, tests, lint, and typecheck all pass. Nice, focused fix.

One small follow-up (not blocking): the GET/DELETE path has no test yet, and an explicit null is treated differently there (no input) than in POST (input: null). Worth a quick test and a decision on that case later.

@dkotter

dkotter commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Would be great if we can ensure the PR template is followed here. Noticing the Use of AI Tools and Changelog Entry sections aren't provided right now and the Testing Instructions section just includes automated test steps whereas we want manual test steps there

@dkotter dkotter added this to the 1.1.0 milestone Jun 25, 2026
@jeffpaul jeffpaul moved this from Triage to In progress in WordPress AI Roadmap Jun 26, 2026
@jeffpaul jeffpaul modified the milestones: 1.1.0, 1.2.0 Jun 26, 2026
@jeffpaul jeffpaul marked this pull request as draft June 26, 2026 17:34
@jorgefilipecosta jorgefilipecosta force-pushed the codex/run-ability-omitted-input branch from afb164a to ddfc25b Compare June 29, 2026 09:15
@jorgefilipecosta jorgefilipecosta force-pushed the codex/run-ability-omitted-input branch from ddfc25b to 3bd37af Compare June 29, 2026 09:27
@jorgefilipecosta jorgefilipecosta force-pushed the codex/run-ability-omitted-input branch from 3bd37af to 8d34d98 Compare June 29, 2026 12:36
@jorgefilipecosta

Copy link
Copy Markdown
Member Author

Would be great if we can ensure the PR template is followed here. Noticing the Use of AI Tools and Changelog Entry sections aren't provided right now and the Testing Instructions section just includes automated test steps whereas we want manual test steps there

The description was updated 👍

@jorgefilipecosta jorgefilipecosta marked this pull request as ready for review June 29, 2026 15:13
@dkotter dkotter modified the milestones: 1.2.0, 1.1.0 Jun 29, 2026
@dkotter dkotter merged commit a153f3f into develop Jun 29, 2026
27 checks passed
@github-project-automation github-project-automation Bot moved this from In progress to Done in WordPress AI Roadmap Jun 29, 2026
@dkotter dkotter deleted the codex/run-ability-omitted-input branch June 29, 2026 17:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants