Skip to content

seed-validation-env.sh greps comments, so documenting a compose guard breaks validation #107

Description

@Gerrrt

scripts/seed-validation-env.sh:41-46 discovers compose's required-variable
guards by grepping the raw file:

grep -oE '\$\{[A-Za-z_][A-Za-z0-9_]*:\?' "${STACK}/compose.yaml"

That reads YAML comments as well as YAML. Writing a comment in compose.yaml
that mentions the guard syntax — explaining what one does, for instance —
makes the script demand a throwaway value for a variable that does not exist,
and make validate fails with:

compose.yaml guards VAR, which the validation .env does not set.
Add a throwaway value for it to ./scripts/seed-validation-env.sh

Hit this for real while writing #62; the fix was to reword the comment, which is
the wrong way round — documentation should not have to avoid describing the
thing it documents.

The script is otherwise a good piece of work, and the check it performs is
worth keeping: it exists because CI and validate.sh once drifted and a new
guard passed locally and failed in CI.

Fix

Read the parsed structure rather than the text — docker compose config will
not resolve the guards, but python3 -c "import yaml; ..." over the raw file
gives values without comments, and check_compose_health.py already parses
compose.yaml with PyYAML, so the dependency is present.

Failing that, strip comment lines before grepping. Less correct, one line.

Found while verifying #12.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions