Improve compose validation errors #492

Open
opened 2025-01-23 02:07:46 +00:00 by marlon · 3 comments

When trying to substitute an env var for a value in a recipe config file, abra sometimes gives an error like:

FATA[0000] unable to validate recipe: error while interpolating services.ssh.ports.[].published: failed to cast to expected type: strconv.Atoi: parsing "": invalid syntax caller="/drone/src/cli/internal/validate.go:71 ValidateRecipe" stack="/drone/src/cli/internal/validate.go:71

Steps to reproduce:

Create a recipe with a compose file that includes, for example, a section with

    ports:
      - target: 22
        published: ${PORT}

Run abra app new mynewrecipe

Get error

When trying to substitute an env var for a value in a recipe config file, abra sometimes gives an error like: `FATA[0000] unable to validate recipe: error while interpolating services.ssh.ports.[].published: failed to cast to expected type: strconv.Atoi: parsing "": invalid syntax caller="/drone/src/cli/internal/validate.go:71 ValidateRecipe" stack="/drone/src/cli/internal/validate.go:71` ### Steps to reproduce: Create a recipe with a compose file that includes, for example, a section with ``` ports: - target: 22 published: ${PORT} ``` Run `abra app new mynewrecipe` Get error
Owner

Thanks for the report @marlon ! I'm not super familiar with Go but it seems Atoi is trying to cast to an integer; maybe it would help to provide a default e.g. published: ${PORT:-22}?

Thanks for the report @marlon ! I'm not super familiar with Go but it seems `Atoi` is trying to cast to an integer; maybe it would help to provide a default e.g. `published: ${PORT:-22}`?
Owner

Yeh @marlon I think @3wordchant hit the nail on the head here. Also you can check that you're threading the PORT=... through in the .env file also?

Yeh @marlon I think @3wordchant hit the nail on the head here. Also you can check that you're threading the `PORT=...` through in the `.env` file also?
decentral1se added the
question
label 2025-02-05 15:22:33 +00:00
Owner

In the same spirit as #525 I think we should try to catch these errors and reinterpret them to something that someone who doesn't know internals can make sense of.

In the same spirit as https://git.coopcloud.tech/toolshed/abra/pulls/525 I think we should try to catch these errors and reinterpret them to something that someone who doesn't know internals can make sense of.
decentral1se added
enhancement
and removed
question
labels 2025-03-23 09:42:24 +00:00
decentral1se changed title from valid env variable substitution in compose file throws an error to Improve compose validation errors 2025-03-23 09:42:51 +00:00
decentral1se added this to the Abra v0.10.1 project 2025-04-20 05:48:30 +00:00
decentral1se moved this to Backlog in Abra v0.10.1 on 2025-04-20 06:06:40 +00:00
decentral1se moved this to Backlog in Abra v0.10.1 on 2025-04-21 19:08:15 +00:00
decentral1se moved this to Backlog in Abra v0.10.1 on 2025-04-21 19:08:25 +00:00
decentral1se moved this to Backlog in Abra v0.10.1 on 2025-04-24 08:58:35 +00:00
decentral1se moved this to Backlog in Abra v0.10.1 on 2025-04-24 08:58:37 +00:00
decentral1se moved this to Backlog in Abra v0.10.1 on 2025-04-24 08:58:38 +00:00
decentral1se removed this from the Abra v0.10.1 project 2025-04-24 09:00:51 +00:00
decentral1se added this to the Abra "next" project 2025-04-24 19:38:01 +00:00
decentral1se moved this to Backlog in Abra "next" on 2025-05-11 08:24:52 +00:00
Sign in to join this conversation.
3 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: toolshed/abra#492
No description provided.