Skip to content

[FrameworkBundle] lint:container should check if referenced env variables exist #58105

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
ostrolucky opened this issue Aug 27, 2024 · 1 comment · Fixed by #58199
Closed

[FrameworkBundle] lint:container should check if referenced env variables exist #58105

ostrolucky opened this issue Aug 27, 2024 · 1 comment · Fixed by #58199

Comments

@ostrolucky
Copy link
Contributor

Description

It's common mistake in our teams to define environment variable for one environment (eg. staging), but not the other (eg. production). Deploying such application with such configuration works and even most of the routes, but once one of the route needs service that requires the env var, at that point things blow up with this error

Noticed exception 'Symfony\Component\DependencyInjection\Exception\EnvNotFoundException' with message 'Environment variable not found: "PM_DC_TOKEN".' in /srv/api/vendor/symfony/dependency-injection/EnvVarProcessor.php:221

So I thought one neat way how I can avoid such issues in future is to add CI job which runs bin/console lint:container - both during CI run and during deployment, however this command does not complain about this. I'm wondering what else I can do?

symfony version I use: 7.1.3

Example

No response

@nicolas-grekas
Copy link
Member

I'd suggest putting this check behind a flag because I'm pretty sure there are many use cases where linting happens at a time where not all env vars are available. Up for a PR?

nicolas-grekas added a commit that referenced this issue Sep 16, 2024
…lint:container` command (ostrolucky)

This PR was merged into the 7.2 branch.

Discussion
----------

[FrameworkBundle] Add `--resolve-env-vars` option to `lint:container` command

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

Commits
-------

76bab40 [FrameworkBundle] Add --resolve-env-vars option to lint:container command
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