Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Inline yaml comments broken after recent commit #59378

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
alexpott opened this issue Jan 6, 2025 · 0 comments · Fixed by #59381
Closed

Inline yaml comments broken after recent commit #59378

alexpott opened this issue Jan 6, 2025 · 0 comments · Fixed by #59381

Comments

@alexpott
Copy link
Contributor

alexpott commented Jan 6, 2025

Symfony version(s) affected

6.4

Description

The yaml parser errors on inline comments after 8a3a57d

How to reproduce

Parse the following yaml before and after 8a3a57d

calls:
  # This is a temporary measure. JSON:API should not need to be aware of the Content Moderation module.
  - [setLatestRevisionCheck, ['@?access_check.latest_revision']] # This is only injected when the service is available.

using the following code:

use Symfony\Component\Yaml\Yaml;

$a = <<<YML
calls:
  # This is a temporary measure. JSON:API should not need to be aware of the Content Moderation module.
  - [setLatestRevisionCheck, ['@?access_check.latest_revision']] # This is only injected when the service is available.
YML;

dump(Yaml::parse($a));

before this will output:

^ array:1 [
  "calls" => array:1 [
    0 => array:2 [
      0 => "setLatestRevisionCheck"
      1 => array:1 [
        0 => "@?access_check.latest_revision"
      ]
    ]
  ]
]

after this will output

PHP Fatal error:  Uncaught Symfony\Component\Yaml\Exception\ParseException: Unexpected token "# This is only injected when the service is available." at line 3 (near "- [setLatestRevisionCheck, ['@?access_check.latest_revision']] # This is only injected when the service is available."). in /Volumes/dev/symfony/src/Symfony/Component/Yaml/Parser.php:1210

Possible Solution

No response

Additional Context

No response

@alexpott alexpott added the Bug label Jan 6, 2025
@xabbuh xabbuh added the Yaml label Jan 6, 2025
nicolas-grekas added a commit that referenced this issue Jan 7, 2025
This PR was squashed before being merged into the 6.4 branch.

Discussion
----------

[Yaml] fix inline notation with inline comment

| Q             | A
| ------------- | ---
| Branch?       | 6.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Issues        | Fix #59378
| License       | MIT

Recent commit broke parsing yam like:
```yaml
calls:
  # This is a temporary measure. JSON:API should not need to be aware of the Content Moderation module.
  - [setLatestRevisionCheck, ['@?access_check.latest_revision']] # This is only injected when the service is available.
```

This MR adds a test and fixes this.

Commits
-------

dccac0b [Yaml] fix inline notation with inline comment
@xabbuh xabbuh closed this as completed Jan 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants