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

[Bug]: Failed to parse dotenv file. Encountered unexpected whitespace. #4675

Open
TotalLag opened this issue Dec 26, 2024 · 1 comment
Open
Labels
🐛 Bug Reported issues that need to be reproduced by the team. 🔍 Triage Issues that need assessment and prioritization.

Comments

@TotalLag
Copy link

Error Message and Logs

When deploying an application through Coolify, the build fails during the environment parsing step. Although the error message initially looks related to Composer, further investigation shows that Coolify itself struggles to parse a .env variable containing quotes and whitespace (e.g., a Content Security Policy string).

Error message snippet:

Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
The environment file is invalid!
Failed to parse dotenv file. Encountered unexpected whitespace at ["default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline';"].
Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1
Plugins have been disabled automatically as you are running as root, this may be the cause of the script failure.
See also https://getcomposer.org/root

I've tried various methods (e.g., "Is Literal", Build Variable, adding quotes manually) to successfully parse this environment variable, but the build still fails.

Steps to Reproduce

Steps to Reproduce

  1. Deploy an application using Coolify with a .env variable that includes a CSP directive with quotes, for example:
CONTENT_SECURITY_POLICY="default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline';"
  1. Trigger a build/deployment within Coolify.
  2. Observe the error in the logs indicating a failure to parse the .env file due to unexpected whitespace or quotes.

Example Repository URL

No response

Coolify Version

v4.0.0-beta.379

Are you using Coolify Cloud?

No (self-hosted)

Operating System and Version (self-hosted)

Ubuntu 22.04

Additional Information

No response

@TotalLag TotalLag added 🐛 Bug Reported issues that need to be reproduced by the team. 🔍 Triage Issues that need assessment and prioritization. labels Dec 26, 2024
@TotalLag
Copy link
Author

The workaround I found to work is just to flip the quotes and check Is Literal:

CONTENT_SECURITY_POLICY='default-src "self"; script-src "self" "unsafe-inline" "unsafe-eval"; style-src "self" "unsafe-inline";'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Bug Reported issues that need to be reproduced by the team. 🔍 Triage Issues that need assessment and prioritization.
Projects
None yet
Development

No branches or pull requests

1 participant