Fix: Ensure YAML formatter outputs scalar values correctly#6158
Open
adityaanurag0219 wants to merge 8 commits intowp-cli:mainfrom
Open
Fix: Ensure YAML formatter outputs scalar values correctly#6158adityaanurag0219 wants to merge 8 commits intowp-cli:mainfrom
adityaanurag0219 wants to merge 8 commits intowp-cli:mainfrom
Conversation
- Updated in to handle scalar values properly in YAML. - Added functional feature test to verify YAML output for scalars and strings.
Previously, scalars like 0 and 'hello' were incorrectly rendered as YAML lists. This patch updates the YAML formatter to correctly handle scalar values and adds feature tests to verify output.
This patch updates YAML formatter logic to handle all scalar types (0, string, null, true, false) correctly. Previously, scalars like 0 or null were incorrectly rendered. Added feature tests for these cases to prevent regressions.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Member
|
Similar to #6188, I think this is best handled directly in the Spyc repo. See wp-cli/spyc#3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix: Ensure YAML formatter outputs scalar values (e.g., 0, strings) correctly
Description
This PR resolves an issue where scalar values were incorrectly rendered by the YAML formatter in WP-CLI.
Previously, scalars such as
0or"hello"were being output as YAML lists instead of simple scalar values.Problem
When running commands with
--format=yaml, scalar values were misrepresented:This behavior is inconsistent with expected YAML scalar formatting and can cause confusion or break automation pipelines that rely on precise YAML output.
Fix
Verification (After Fix)
Tests
Checklist
Notes on CI Failures
codecov/patch: Shows 0% diff hit because Behat feature tests are not included in Codecov coverage reports. However, additional scenarios were added that do exercise the new code paths.
Functional tests on WP trunk + PHP nightly (MySQL/SQLite): These jobs are known to be unstable. All stable PHP/MySQL builds pass successfully, indicating this patch is safe.
Related Issue
Fixes #6094