Skip to content

Fix Abilities Explorer input schema validation#787

Merged
dkotter merged 5 commits into
WordPress:developfrom
dkotter:fix/ability-explorer-validation-bug
Jun 30, 2026
Merged

Fix Abilities Explorer input schema validation#787
dkotter merged 5 commits into
WordPress:developfrom
dkotter:fix/ability-explorer-validation-bug

Conversation

@dkotter

@dkotter dkotter commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

What?

Closes https://wordpress.org/support/topic/bug-ability_handlervalidate_input-wont-accept-scalar-inputs/

Ensure when we validate the input schema in the Abilities Explorer page we allow both array and scalar inputs

Why?

Abilities can have input schemas that are just scalar (like a single post ID) and also support input schemas that are arrays. Our validation we run in the Abilities Explorer was only allowing array schemas so any Abilities that had scalar schemas were rejected.

How?

Remove the array type hint on both invoke_ability and validate_input so scalar schemas can be used.

Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code
Model(s): Opus 4.8
Used for: Validating bug, suggesting a fix and executing that fix. Final review and testing by me

Testing Instructions

  1. Enable the Abilities Explorer feature
  2. Go to Tools > Abilities Explorer
  3. Choose an Ability from the list and click on it (like Get Environment Info)
  4. Click the Test Ability button
  5. From here, click the Validate Input button to ensure the schema validates correctly
  6. Click the Invoke Ability and ensure the Ability is triggered successfully

Changelog Entry

Fixed - Ensure scalar input schemas are allowed in the Abilities Explorer validation.

Open WordPress Playground Preview

@dkotter dkotter added this to the 1.1.0 milestone Jun 26, 2026
@dkotter dkotter self-assigned this Jun 26, 2026
@github-actions

github-actions Bot commented Jun 26, 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.

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @squarestar.

Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases.

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

Unlinked contributors: squarestar.

Co-authored-by: dkotter <[email protected]>
Co-authored-by: jeffpaul <[email protected]>

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

@codecov

codecov Bot commented Jun 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.57%. Comparing base (d400910) to head (b20616f).

Additional details and impacted files
@@              Coverage Diff              @@
##             develop     #787      +/-   ##
=============================================
+ Coverage      76.48%   76.57%   +0.09%     
- Complexity      1869     1870       +1     
=============================================
  Files             89       89              
  Lines           7990     7992       +2     
=============================================
+ Hits            6111     6120       +9     
+ Misses          1879     1872       -7     
Flag Coverage Δ
unit 76.57% <100.00%> (+0.09%) ⬆️

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.

jeffpaul
jeffpaul previously approved these changes Jun 26, 2026

@jeffpaul jeffpaul 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.

Tested via P{layground and using test steps things worked as expected.

@jeffpaul jeffpaul moved this from Triage to Needs review in WordPress AI Roadmap Jun 26, 2026
@squarestar

Copy link
Copy Markdown

The mark_setting() method in Show_In_Abilities.php is hooked to the register_setting_args filter and has a strict array type declaration for $args. One plugin on my system (WPBakery Page Builder) calls register_setting() with null args, which causes a fatal error. Maybe this method needs to account for issues in plugins? A defensive solution could be:

public function mark_setting( ?array $args, array $defaults, string $option_group, string $option_name ): array {
    $args = $args ?? [];

dkotter added 2 commits June 29, 2026 08:31
…er_setting_args and there's a chance other plugins could hook here and return bad data, resulting in fatals
@dkotter

dkotter commented Jun 29, 2026

Copy link
Copy Markdown
Contributor Author

The mark_setting() method in Show_In_Abilities.php is hooked to the register_setting_args filter and has a strict array type declaration for $args. One plugin on my system (WPBakery Page Builder) calls register_setting() with null args, which causes a fatal error.

Thanks for the flag there. I'd argue that's an issue in that plugin as they shouldn't be returning null for that, they should be using an empty array, but that is a good flag. I've pushed b20616f to remove the typing on these params to avoid these issues, plus adding an is_array check

@jeffpaul jeffpaul mentioned this pull request Jun 29, 2026
32 tasks
@dkotter dkotter enabled auto-merge (squash) June 30, 2026 15:03
@dkotter dkotter disabled auto-merge June 30, 2026 15:04
@dkotter dkotter merged commit 82e7535 into WordPress:develop Jun 30, 2026
39 of 40 checks passed
@github-project-automation github-project-automation Bot moved this from Needs review to Done in WordPress AI Roadmap Jun 30, 2026
@dkotter dkotter deleted the fix/ability-explorer-validation-bug branch June 30, 2026 15:04
@jeffpaul

Copy link
Copy Markdown
Member

@squarestar if you can connect your GitHub and WordPress.org accounts, then I can formally credit you on the release announcement post and grant the AI Contributor badge.

@squarestar

Copy link
Copy Markdown

Thanks but that WP account isn't the one I'd want connected to this GH account. I've connected my WP squarestar account but I used a different one to open the topic on wp.org. No worries if you don't credit me.

@jeffpaul

jeffpaul commented Jul 2, 2026

Copy link
Copy Markdown
Member

@squarestar what's your preferred WPORG account to credit for work on this AI plugin release then?

@squarestar

Copy link
Copy Markdown

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.

3 participants