Skip to content

fix(config): strip matching surrounding quotes from env values - #9

Merged
IceCodeNew merged 1 commit into
masterfrom
shit/docker/env-file
Jul 13, 2026
Merged

fix(config): strip matching surrounding quotes from env values#9
IceCodeNew merged 1 commit into
masterfrom
shit/docker/env-file

Conversation

@IceCodeNew

Copy link
Copy Markdown
Owner

Docker run --env-file treats KEY='value' as a literal string including the single quotes, unlike shell source .env. Similarly, docker-compose env_file can inject wrapping quotes into the container environment depending on the parser dialect.

What changed

  • Added _clean_env() — strips leading/trailing whitespace, then removes a matched pair of surrounding single or double quotes. Unmatched quotes (e.g. a token legitimately ending with ') are left intact.
  • All os.getenv() calls in Settings.from_env() and helper functions (_required, _integer, _float, _cron_hour, _configured_weather_providers) now pass through _clean_env().
  • env.example now warns against quoting values for Docker compatibility.
  • docs/design.md documents the rationale under a new "Environment variable compatibility" section.

Tests

Added 8 tests covering single quotes, double quotes, unquoted values, quoted numeric values, empty quoted strings → None, and unmatched quotes left unchanged.

Docker `run --env-file` treats `KEY='value'` as a literal string
including the single quotes, unlike shell `source .env`. Similarly,
docker-compose `env_file` can inject wrapping quotes into the container
environment depending on the parser dialect.

Introduce `_clean_env()` that strips whitespace and then removes a
matched pair of single or double quotes (value[0] == value[-1]).
All `os.getenv()` calls in `Settings.from_env()` and helper functions
(`_required`, `_integer`, `_float`, `_cron_hour`,
`_configured_weather_providers`) now pass through `_clean_env()`.

The cleanup is conservative: unmatched or nested quotes are
left intact so legitimate values like tokens ending with a quote
are not corrupted.
@IceCodeNew
IceCodeNew force-pushed the shit/docker/env-file branch from 94556c1 to 47ae711 Compare July 13, 2026 18:29
@IceCodeNew
IceCodeNew merged commit a304ea4 into master Jul 13, 2026
18 checks passed
@IceCodeNew
IceCodeNew deleted the shit/docker/env-file branch July 13, 2026 18:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant