Errors in .env.sample are not reported in a useful way. #762

Open
opened 2026-01-29 18:05:35 +00:00 by amras · 1 comment

Background

Operator Scenario: Helpful

  1. I am an operator.
  2. I make a typo while editing a config: I accidentally add a dash to a variable name.
  3. I try to deploy my app.
  4. I get a legible error which tells me what needs to be fixed.
$ abra app deploy example.com
FATA env file for example.com couldn't be read: unexpected character "-" in variable name near "EVIL-VAR=error\n"

This is good.

Maintainer Scenario: Not Helpful

  1. I am a maintainer.
  2. I make a typo while editing .env.sample: I accidentally add a dash to a variable name.
  3. I try to create or deploy an app using my recipe.
  4. I get a vague error, which doesn't tell me what needs to be fixed.
FATA unable to validate recipe: unable to discover .env.sample for mvp

Reproduction

Error on app new

$ abra recipe new mvp
$ cd mvp
$ echo "EVIL-VAR=error" >> .env.sample
$ abra app new mvp -D mvp.example.com -C

FATA unable to validate recipe: unable to discover .env.sample for mvp

Error on app deploy

$ abra recipe new mvp
$ cd mvp
$ abra app new mvp -D mvp.example.com -C
$ echo "EVIL-VAR=error" >> .env.sample
$ abra app deploy mvp.example.com -C

WARN recipe 'mvp' failed lint checks:
lint R009: unable to discover .env.sample for mvp
 * one service named 'app' (R009)
lint R015: unable to discover .env.sample for mvp
 * deploy labels stanza present (R015)
lint R010: unable to discover .env.sample for mvp
 * traefik routing enabled (R010)
lint R011: unable to discover .env.sample for mvp
 * all services have images (R011)
lint R012: unable to discover .env.sample for mvp
 * config version are vendored (R012)
FATA unable to discover .env.sample for mvp

Proposed Solution

When deploying a recipe, abra should show equivalent error messages, regardless of whether the error occured in .env or .env.sample.

Specifically:

When executing either of the reproductions above, we should see the same message as in the operator scenario, i.e.:

FATA .env.sample file for mvp.example.com couldn't be read: unexpected character "-" in variable name near "EVIL-VAR=error\n"
## Background ### Operator Scenario: Helpful 1. I am an operator. 2. I make a typo while editing a config: I accidentally add a dash to a variable name. 3. I try to deploy my app. 4. I get a legible error which tells me what needs to be fixed. ```bash $ abra app deploy example.com FATA env file for example.com couldn't be read: unexpected character "-" in variable name near "EVIL-VAR=error\n" ``` This is good. ### Maintainer Scenario: Not Helpful 1. I am a maintainer. 2. I make a typo while editing `.env.sample`: I accidentally add a dash to a variable name. 3. I try to create or deploy an app using my recipe. 4. I get a vague error, which doesn't tell me what needs to be fixed. ``` FATA unable to validate recipe: unable to discover .env.sample for mvp ``` ## Reproduction ### Error on `app new` ```bash $ abra recipe new mvp $ cd mvp $ echo "EVIL-VAR=error" >> .env.sample $ abra app new mvp -D mvp.example.com -C FATA unable to validate recipe: unable to discover .env.sample for mvp ``` ### Error on `app deploy` ```bash $ abra recipe new mvp $ cd mvp $ abra app new mvp -D mvp.example.com -C $ echo "EVIL-VAR=error" >> .env.sample $ abra app deploy mvp.example.com -C WARN recipe 'mvp' failed lint checks: lint R009: unable to discover .env.sample for mvp * one service named 'app' (R009) lint R015: unable to discover .env.sample for mvp * deploy labels stanza present (R015) lint R010: unable to discover .env.sample for mvp * traefik routing enabled (R010) lint R011: unable to discover .env.sample for mvp * all services have images (R011) lint R012: unable to discover .env.sample for mvp * config version are vendored (R012) FATA unable to discover .env.sample for mvp ``` ## Proposed Solution When deploying a recipe, abra should show equivalent error messages, regardless of whether the error occured in .env or .env.sample. Specifically: When executing either of the reproductions above, we should see the same message as in the operator scenario, i.e.: ```bash FATA .env.sample file for mvp.example.com couldn't be read: unexpected character "-" in variable name near "EVIL-VAR=error\n" ```
Author

Debug output for completeness:

Operator Scenario

$ abra app deploy mvp.example.com -C --debug
DEBU <cli/run.go:137> abra version: 0.12.0-beta, commit: db7c4042, lang: en
DEBU <app/app.go:295> collecting metadata from 2 servers: .git, default
FATA <internal/validate.go:103> env file for mvp.example.com couldn't be read: unexpected character "-" in variable name near "EVIL-VAR=broken\n"

Reproduction / Error on app new

$ abra app new mvp -D mvp.example.com -C --debug
DEBU <cli/run.go:137> abra version: 0.12.0-beta, commit: db7c4042, lang: en
DEBU <git/branch.go:99> successfully checked out refs/heads/main in /home/admin/.abra/catalogue
DEBU <catalogue/catalogue.go:84> fetched latest git changes for /home/admin/.abra/catalogue
DEBU <recipe/recipe.go:406> read recipe catalogue from file system cache in /home/admin/.abra/catalogue/recipes.json
DEBU <git/read.go:130> no /home/admin/.gitignore exists, skipping reading gitignore paths
DEBU <git/read.go:50> git status: /home/admin/.abra/recipes/mvp:  M .env.sample
FATA <internal/validate.go:84> unable to validate recipe: unable to discover .env.sample for mvp

Reproduction / Error on app deploy

$ abra app deploy mvp.example.com -C --debug
DEBU <cli/run.go:137> abra version: 0.12.0-beta, commit: db7c4042, lang: en
DEBU <app/app.go:295> collecting metadata from 2 servers: .git, default
DEBU <git/read.go:130> no /home/admin/.gitignore exists, skipping reading gitignore paths
DEBU <git/read.go:50> git status: /home/admin/.abra/recipes/mvp:  M .env.sample
DEBU <app/app.go:41> loaded app mvp.example.com: {name: mvp.example.com, recipe: {name: mvp, version : 0467921b, dirty: true, dir: /home/admin/.abra/recipes/mvp, git url: https://git.coopcloud.tech/coop-cloud/mvp.git, ssh url: ssh://git@git.coopcloud.tech:2222/coop-cloud/mvp.git, compose: /home/admin/.abra/recipes/mvp/compose.yml, readme: /home/admin/.abra/recipes/mvp/README.md, sample env: /home/admin/.abra/recipes/mvp/.env.sample, abra.sh: /home/admin/.abra/recipes/mvp/abra.sh}, domain: mvp.example.com, env map[DOMAIN:mvp.example.com LETS_ENCRYPT_ENV:production TYPE:mvp:0467921b], server default, path /home/admin/.abra/servers/default/mvp.example.com.env}
DEBU <internal/validate.go:106> validated mvp.example.com as app argument
DEBU <client/client.go:111> created client for default
DEBU <app/deploy.go:94> checking whether mvp_example_com is already deployed
DEBU <stack/stack.go:174> mvp_example_com has been detected as not deployed
DEBU <git/read.go:130> no /home/admin/.gitignore exists, skipping reading gitignore paths
DEBU <git/read.go:50> git status: /home/admin/.abra/recipes/mvp:  M .env.sample
DEBU <app/deploy.go:354> version: taking chaos version: 0467921b+U
DEBU <lint/recipe.go:187> linting for critical errors in mvp configs
DEBU <lint/recipe.go:52> R010: skip condition: unable to discover .env.sample for mvp
WARN <app/deploy.go:123> recipe 'mvp' failed lint checks:
lint R009: unable to discover .env.sample for mvp
 * one service named 'app' (R009)
lint R015: unable to discover .env.sample for mvp
 * deploy labels stanza present (R015)
lint R010: unable to discover .env.sample for mvp
 * traefik routing enabled (R010)
lint R011: unable to discover .env.sample for mvp
 * all services have images (R011)
lint R012: unable to discover .env.sample for mvp
 * config version are vendored (R012)
DEBU <recipe/compose.go:29> no COMPOSE_FILE detected, loading default: /home/admin/.abra/recipes/mvp/compose.yml
DEBU <envfile/envfile.go:42> read map[DOMAIN:mvp.example.com LETS_ENCRYPT_ENV:production TYPE:mvp:0467921b] from /home/admin/.abra/servers/default/mvp.example.com.env
DEBU <secret/secret.go:124> not generating app secrets, none enabled in recipe config
DEBU <recipe/compose.go:29> no COMPOSE_FILE detected, loading default: /home/admin/.abra/recipes/mvp/compose.yml
DEBU <envfile/envfile.go:42> read map[DOMAIN:mvp.example.com LETS_ENCRYPT_ENV:production TYPE:mvp:0467921b] from /home/admin/.abra/servers/default/mvp.example.com.env
DEBU <secret/secret.go:124> not generating app secrets, none enabled in recipe config
DEBU <envfile/envfile.go:82> read 0 env var exports from /home/admin/.abra/recipes/mvp/abra.sh
DEBU <recipe/compose.go:29> no COMPOSE_FILE detected, loading default: /home/admin/.abra/recipes/mvp/compose.yml
DEBU <app/app.go:499> retrieved /home/admin/.abra/recipes/mvp/compose.yml for mvp.example.com
DEBU <app/compose.go:18> set recipe label 'coop-cloud.mvp_example_com.recipe' to mvp for mvp_example_com
DEBU <app/compose.go:30> set label 'coop-cloud.mvp_example_com.chaos' to true for mvp_example_com
DEBU <app/compose.go:41> set label 'coop-cloud.mvp_example_com.chaos-version' to 0467921b+U for mvp_example_com
DEBU <app/compose.go:51> set label 'coop-cloud.mvp_example_com.version' to  for mvp_example_com
DEBU <app/app.go:512> adding env vars to mvp_example_com service config
DEBU <app/app.go:523> mvp_example_com: TYPE: mvp:0467921b+U
DEBU <app/app.go:523> mvp_example_com: DOMAIN: mvp.example.com
DEBU <app/app.go:523> mvp_example_com: LETS_ENCRYPT_ENV: production
DEBU <app/app.go:523> mvp_example_com: STACK_NAME: mvp_example_com
FATA <app/deploy.go:178> unable to discover .env.sample for mvp
Debug output for completeness: ### Operator Scenario ```bash $ abra app deploy mvp.example.com -C --debug DEBU <cli/run.go:137> abra version: 0.12.0-beta, commit: db7c4042, lang: en DEBU <app/app.go:295> collecting metadata from 2 servers: .git, default FATA <internal/validate.go:103> env file for mvp.example.com couldn't be read: unexpected character "-" in variable name near "EVIL-VAR=broken\n" ``` ### Reproduction / Error on `app new` ```bash $ abra app new mvp -D mvp.example.com -C --debug DEBU <cli/run.go:137> abra version: 0.12.0-beta, commit: db7c4042, lang: en DEBU <git/branch.go:99> successfully checked out refs/heads/main in /home/admin/.abra/catalogue DEBU <catalogue/catalogue.go:84> fetched latest git changes for /home/admin/.abra/catalogue DEBU <recipe/recipe.go:406> read recipe catalogue from file system cache in /home/admin/.abra/catalogue/recipes.json DEBU <git/read.go:130> no /home/admin/.gitignore exists, skipping reading gitignore paths DEBU <git/read.go:50> git status: /home/admin/.abra/recipes/mvp: M .env.sample FATA <internal/validate.go:84> unable to validate recipe: unable to discover .env.sample for mvp ``` ### Reproduction / Error on `app deploy` ```bash $ abra app deploy mvp.example.com -C --debug DEBU <cli/run.go:137> abra version: 0.12.0-beta, commit: db7c4042, lang: en DEBU <app/app.go:295> collecting metadata from 2 servers: .git, default DEBU <git/read.go:130> no /home/admin/.gitignore exists, skipping reading gitignore paths DEBU <git/read.go:50> git status: /home/admin/.abra/recipes/mvp: M .env.sample DEBU <app/app.go:41> loaded app mvp.example.com: {name: mvp.example.com, recipe: {name: mvp, version : 0467921b, dirty: true, dir: /home/admin/.abra/recipes/mvp, git url: https://git.coopcloud.tech/coop-cloud/mvp.git, ssh url: ssh://git@git.coopcloud.tech:2222/coop-cloud/mvp.git, compose: /home/admin/.abra/recipes/mvp/compose.yml, readme: /home/admin/.abra/recipes/mvp/README.md, sample env: /home/admin/.abra/recipes/mvp/.env.sample, abra.sh: /home/admin/.abra/recipes/mvp/abra.sh}, domain: mvp.example.com, env map[DOMAIN:mvp.example.com LETS_ENCRYPT_ENV:production TYPE:mvp:0467921b], server default, path /home/admin/.abra/servers/default/mvp.example.com.env} DEBU <internal/validate.go:106> validated mvp.example.com as app argument DEBU <client/client.go:111> created client for default DEBU <app/deploy.go:94> checking whether mvp_example_com is already deployed DEBU <stack/stack.go:174> mvp_example_com has been detected as not deployed DEBU <git/read.go:130> no /home/admin/.gitignore exists, skipping reading gitignore paths DEBU <git/read.go:50> git status: /home/admin/.abra/recipes/mvp: M .env.sample DEBU <app/deploy.go:354> version: taking chaos version: 0467921b+U DEBU <lint/recipe.go:187> linting for critical errors in mvp configs DEBU <lint/recipe.go:52> R010: skip condition: unable to discover .env.sample for mvp WARN <app/deploy.go:123> recipe 'mvp' failed lint checks: lint R009: unable to discover .env.sample for mvp * one service named 'app' (R009) lint R015: unable to discover .env.sample for mvp * deploy labels stanza present (R015) lint R010: unable to discover .env.sample for mvp * traefik routing enabled (R010) lint R011: unable to discover .env.sample for mvp * all services have images (R011) lint R012: unable to discover .env.sample for mvp * config version are vendored (R012) DEBU <recipe/compose.go:29> no COMPOSE_FILE detected, loading default: /home/admin/.abra/recipes/mvp/compose.yml DEBU <envfile/envfile.go:42> read map[DOMAIN:mvp.example.com LETS_ENCRYPT_ENV:production TYPE:mvp:0467921b] from /home/admin/.abra/servers/default/mvp.example.com.env DEBU <secret/secret.go:124> not generating app secrets, none enabled in recipe config DEBU <recipe/compose.go:29> no COMPOSE_FILE detected, loading default: /home/admin/.abra/recipes/mvp/compose.yml DEBU <envfile/envfile.go:42> read map[DOMAIN:mvp.example.com LETS_ENCRYPT_ENV:production TYPE:mvp:0467921b] from /home/admin/.abra/servers/default/mvp.example.com.env DEBU <secret/secret.go:124> not generating app secrets, none enabled in recipe config DEBU <envfile/envfile.go:82> read 0 env var exports from /home/admin/.abra/recipes/mvp/abra.sh DEBU <recipe/compose.go:29> no COMPOSE_FILE detected, loading default: /home/admin/.abra/recipes/mvp/compose.yml DEBU <app/app.go:499> retrieved /home/admin/.abra/recipes/mvp/compose.yml for mvp.example.com DEBU <app/compose.go:18> set recipe label 'coop-cloud.mvp_example_com.recipe' to mvp for mvp_example_com DEBU <app/compose.go:30> set label 'coop-cloud.mvp_example_com.chaos' to true for mvp_example_com DEBU <app/compose.go:41> set label 'coop-cloud.mvp_example_com.chaos-version' to 0467921b+U for mvp_example_com DEBU <app/compose.go:51> set label 'coop-cloud.mvp_example_com.version' to for mvp_example_com DEBU <app/app.go:512> adding env vars to mvp_example_com service config DEBU <app/app.go:523> mvp_example_com: TYPE: mvp:0467921b+U DEBU <app/app.go:523> mvp_example_com: DOMAIN: mvp.example.com DEBU <app/app.go:523> mvp_example_com: LETS_ENCRYPT_ENV: production DEBU <app/app.go:523> mvp_example_com: STACK_NAME: mvp_example_com FATA <app/deploy.go:178> unable to discover .env.sample for mvp ```
decentral1se added the
bug
label 2026-01-29 22:14:38 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: toolshed/abra#762
No description provided.