8000 [YAML][lint] Can not lint !tagged · Issue #28465 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[YAML][lint] Can not lint !tagged #28465

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
lsv opened this issue Sep 14, 2018 · 5 comments · Fixed by #33651
Closed

[YAML][lint] Can not lint !tagged #28465

lsv opened this issue Sep 14, 2018 · 5 comments · Fixed by #33651

Comments

@lsv
Copy link
lsv commented Sep 14, 2018

Symfony version(s) affected: 4.1 (possible 3.4, where !tagged got introduced)

Description
If you use !tagged in your yaml file, as described under Reference tagged services

bin/console lint:yaml config will throw

  ERROR  in config/services.yaml
  >> Tags support is not enabled. Enable the `Yaml::PARSE_CUSTOM_TAGS` flag to use "!tagged" at line 35 (near "- !tagged app.payment_method").

So the documentation is missing how to set the Yaml::PARSE_CUSTOM_TAGS flag, so its possible to actually lint yaml files.

How to reproduce

Add

Create a MyClass under src

In services.yaml add the following

App\MyClass:
    tags: [!tagged app.myclass]

Run bin/console lint:yaml config

Possible Solution
Always set the Yaml::PARSE_CUSTOM_TAGS when using bin/console lint:yaml or if without custom tags throws error, then try again but with Yaml::PARSE_CUSTOM_TAGS.

Or add a snippet to the documentation, so state how to set Yaml::PARSE_CUSTOM_TAGS

Additional context
Full exception

-> % bin/console lint:yaml config

  ERROR  in config/services.yaml
  >> Tags support is not enabled. Enable the `Yaml::PARSE_CUSTOM_TAGS` flag to use "!tagged" at line 35 (near "- !tagged app.payment_method").

                                                                                                                        
 [WARNING] 49 YAML files have valid syntax and 1 contain errors.                                                        
@xabbuh
Copy link
Member
xabbuh commented Sep 14, 2018

If you want to treat YAML files that make use of tags as valid, you will have to also pass the --parse-tags option:

$ bin/console lint:yaml config --parse-tags

I am going to close here as this is the expected behaviour. Thank you for understanding.

@lsv
Copy link
Author
lsv commented Sep 14, 2018

@xabbuh indeed its fine, but maybe add it to the documentation then? With a little notice block or similar?
https://symfony.com/doc/current/service_container/tags.html#reference-tagged-services

@xabbuh
Copy link
Member
xabbuh commented Sep 14, 2018

Not sure if that's the best place to add it. But we can of course discuss that. Would you like to create an issue in the documentation repository?

@driskell
Copy link
Contributor

Hit this too

Possibly the error should be handled, and the error itself tell you that --parse-tags exists. I ended up here after some digging.

@xabbuh
Copy link
Member
xabbuh commented Sep 20, 2019

see #33651

fabpot added a commit that referenced this issue Sep 23, 2019
…(xabbuh)

This PR was merged into the 4.4 branch.

Discussion
----------

[Yaml] hint to the --parse-tags when parsing tags fails

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | no
| Tickets       | Fix #28465 (comment)
| License       | MIT
| Doc PR        |

Commits
-------

0121115 hint to the --parse-tags when parsing tags fails
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.

4 participants
0