Skip to content
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

bin/console config:dump-reference dumps invalid yaml #54154

Closed
tacman opened this issue Mar 4, 2024 · 4 comments
Closed

bin/console config:dump-reference dumps invalid yaml #54154

tacman opened this issue Mar 4, 2024 · 4 comments

Comments

@tacman
Copy link
Contributor

tacman commented Mar 4, 2024

Symfony version(s) affected

7.0.4

Description

The following yaml, created from config:dump-reference, is invalid, because it has ~ and a list

        # Specifies the default link handling for the web app.
        handle_links:         ~

            # Examples:
            - auto
            - preferred
            - not-preferred

How to reproduce

symfony new container-bug --webapp && cd container-bug
composer install
composer require spomky-labs/pwa-bundle
bin/console config:dump-reference  pwa > pwa.yaml
bin/console lint:yaml pwa.yaml
No security vulnerability advisories found
Using version ^1.0 for spomky-labs/phpwa
  ERROR  in pwa.yaml
  >> Unable to parse at line 8 (near "    - 1").

[WARNING] 0 YAML files have valid syntax and 1 contain errors.

Possible Solution

No response

Additional Context

No response

@tacman tacman added the Bug label Mar 4, 2024
@tacman tacman changed the title bin/console dump:framework-reference dumps invalid yaml bin/console config:dump-reference dumps invalid yaml Mar 4, 2024
@MatTheCat
Copy link
Contributor

Similar to what #39336 fixed, but I don’t understand why array examples never are displayed as comments. Do you remember @Nyholm?

@tacman
Copy link
Contributor Author

tacman commented Mar 18, 2024

in YamlReferenceDumper.php, $message is Examples, and is prefixed by # to comment it out.

But the array is dumped normally, but its lines, too, should be commented out.

            $this->writeLine('# '.$message.':', $depth * 4 + 4);
            $this->writeArray(array_map(Inline::dump(...), $example), $depth + 1);

The test behavior shows this, but it doesn't make much sense, it should be

    variable:

        # Examples:
        # - foo
        # - bar

I'm not sure how to write writeArray to prefix everything with a #, any suggestions?

@MatTheCat
Copy link
Contributor

You could add an optional boolean $asComment argument to WriteArray? If true, then prefix each line with #.

That being said I would have done the same instead of #39336 so maybe we’re missing something 🤔

@tacman
Copy link
Contributor Author

tacman commented Mar 18, 2024

Thanks, I've submitted a PR: #54326

@fabpot fabpot closed this as completed Mar 22, 2024
fabpot added a commit that referenced this issue Mar 22, 2024
This PR was squashed before being merged into the 7.0 branch.

Discussion
----------

[Yaml] prefix examples with #

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

As mentioned in the issue, the yaml before wasn't valid, as the examples were dumped as an array in the yaml.  This simply comments the examples.

Commits
-------

fd95a8f [Yaml] prefix examples with #
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants