Skip to content

Handle wp ability run missing input based on input_schema - #7

Merged
swissspidy merged 7 commits into
mainfrom
copilot/fix-abilities-error-without-input-schema
Jun 14, 2026
Merged

swissspidy merged 7 commits into
mainfrom
copilot/fix-abilities-error-without-input-schema

Conversation

Copilot AI commented Jun 12, 2026 •

Copy link
Copy Markdown
Contributor

wp ability run previously always passed an empty array when no input flags were provided, which caused abilities without an input_schema to fail validation. This PR preserves “no input” as null where appropriate, while keeping compatibility for abilities that do define an input schema.

  • Behavior fix: preserve “no input” semantics without breaking object-schema abilities

    • Updated Ability_Command::build_input_with_stdin() to return null when no --input payload or field args are provided.
    • Updated Ability_Command::run() to pass [] instead of null when no CLI input is provided and the ability defines an input_schema.
    • This keeps abilities without input_schema working as intended, while avoiding input is not of type object errors for abilities that require object input.
  • Regression coverage: ability without input_schema

    • Extended features/ability.feature with a fixture ability (test-plugin/simple-no-input) that defines no input_schema.
    • Added an execution assertion verifying wp ability run test-plugin/simple-no-input returns [].
// Build phase: null when input is truly absent.
return ( empty( $input ) && null === $json_input ) ? null : $input;

// Run phase: for abilities with input_schema, treat missing input as [].
if ( null === $input && null !== $ability->get_meta_item( 'input_schema', null ) ) {
	$input = [];
}

@github-actions github-actions Bot added command:ability-run Related to 'ability run' command scope:testing Related to testing labels Jun 12, 2026
@codecov

codecov Bot commented Jun 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix error for abilities without input_schema when run via CLI Allow wp ability run to execute abilities without input_schema Jun 12, 2026
Copilot AI requested a review from swissspidy June 12, 2026 14:27
@swissspidy
swissspidy requested a review from Copilot June 12, 2026 19:43

This comment was marked as resolved.

swissspidy and others added 2 commits June 12, 2026 22:21
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@swissspidy

This comment was marked as resolved.

@swissspidy swissspidy added this to the 1.0.1 milestone Jun 12, 2026
Copilot AI and others added 2 commits June 12, 2026 20:54
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>

This comment was marked as resolved.

Copilot AI changed the title Allow wp ability run to execute abilities without input_schema Handle wp ability run missing input based on input_schema Jun 12, 2026
@swissspidy

Copy link
Copy Markdown
Member

@copilot fix failing test

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>

This comment was marked as resolved.

@swissspidy
swissspidy marked this pull request as ready for review June 13, 2026 15:00
@swissspidy
swissspidy requested a review from a team as a code owner June 13, 2026 15:00
@swissspidy
swissspidy merged commit 8977ae8 into main Jun 14, 2026
62 checks passed
@swissspidy
swissspidy deleted the copilot/fix-abilities-error-without-input-schema branch June 14, 2026 19:38
@swissspidy swissspidy linked an issue Jun 16, 2026 that may be closed by this pull request
2 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

command:ability-run Related to 'ability run' command scope:testing Related to testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Abilities without input_schema return an error when run via the CLI

3 participants