Skip to content

Keep failed update output parseable for JSON and CSV#529

Merged
swissspidy merged 3 commits into
wp-cli:mainfrom
ekamran:fix-update-structured-output-errors
Jun 10, 2026
Merged

Keep failed update output parseable for JSON and CSV#529
swissspidy merged 3 commits into
wp-cli:mainfrom
ekamran:fix-update-structured-output-errors

Conversation

@ekamran

@ekamran ekamran commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #161.

This fixes the output for failed plugin updates when using --format=json or --format=csv.

Before this change, the command could print structured output first and then append an error message after it. That made the JSON or CSV output hard to parse in scripts.

Changes

  • Keep JSON and CSV update output parseable when an update fails.
  • Still return exit code 1 for failed updates.
  • Add regression tests for failed plugin update output in JSON and CSV formats.

Testing

  • composer lint
  • composer phpcs
  • composer phpstan
  • git diff --check
  • composer behat features/plugin-update.feature -- --name 'Failed plugin update keeps JSON output parseable'
  • composer behat features/plugin-update.feature -- --name 'Failed plugin update keeps CSV output parseable'
  • composer behat features/plugin-update.feature -- --name 'Skip plugin update when plugin directory is a VCS checkout'

@ekamran ekamran requested a review from a team as a code owner June 4, 2026 14:07
@github-actions

github-actions Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Hello! 👋

Thanks for opening this pull request! Please check out our contributing guidelines. We appreciate you taking the initiative to contribute to this project.

Contributing isn't limited to just code. We encourage you to contribute in the way that best fits your abilities, by writing tutorials, giving a demo at your local meetup, helping other users with their support questions, or revising our documentation.

Here are some useful Composer commands to get you started:

  • composer install: Install dependencies.
  • composer test: Run the full test suite.
  • composer phpcs: Check for code style violations.
  • composer phpcbf: Automatically fix code style violations.
  • composer phpunit: Run unit tests.
  • composer behat: Run behavior-driven tests.

To run a single Behat test, you can use the following command:

# Run all tests in a single file
composer behat features/some-feature.feature

# Run only a specific scenario (where 123 is the line number of the "Scenario:" title)
composer behat features/some-feature.feature:123

You can find a list of all available Behat steps in our handbook.

@github-actions github-actions Bot added bug command:plugin-update Related to 'plugin update' command scope:testing Related to testing labels Jun 4, 2026
@codecov

codecov Bot commented Jun 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes malformed machine-readable output when wp plugin update fails under --format=json or --format=csv, ensuring scripts can reliably parse the output while still signaling failure via exit code 1.

Changes:

  • Exit early with status 1 for failed updates in JSON/CSV mode to prevent report_batch_operation_results() from emitting an error message after structured output.
  • Add Behat regression coverage for failed plugin update output in JSON and CSV formats.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/WP_CLI/CommandWithUpgrade.php Halts with exit code 1 on update failures when using JSON/CSV output to keep structured output parseable.
features/plugin-update.feature Adds regression scenarios asserting JSON/CSV output remains parseable on failed plugin updates and exit code is 1.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@swissspidy swissspidy added this to the 2.3.6 milestone Jun 10, 2026
@swissspidy swissspidy merged commit edbfb7b into wp-cli:main Jun 10, 2026
62 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug command:plugin-update Related to 'plugin update' command scope:testing Related to testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Malformed JSON Output - Error on plugin update

3 participants