fix(parsing): accept list-form environment (- KEY=value) alongside map form#83
Open
Cyb3rDudu wants to merge 2 commits intoMcrich23:mainfrom
Open
fix(parsing): accept list-form environment (- KEY=value) alongside map form#83Cyb3rDudu wants to merge 2 commits intoMcrich23:mainfrom
Cyb3rDudu wants to merge 2 commits intoMcrich23:mainfrom
Conversation
…p form
Compose spec allows both shapes for `services.<svc>.environment`:
environment: environment:
KEY: value - KEY=value
OTHER: value equivalent - OTHER=value
- INHERIT_FROM_HOST
Current decode is typed strictly as `[String: String]?` and throws
`DecodingError.typeMismatch` on the list form, failing the whole compose
file. List form is the older docker-classic style still used by Docker
Registry, Sentry, GitLab and many official examples.
Tries the map form first (no behavior change for existing users), falls
back to a small parser:
- `KEY=value` splits on first `=` (later `=` chars stay in the value)
- bare `KEY` reads from `ProcessInfo.processInfo.environment[KEY]`,
falling back to empty string when unset
Fixes Mcrich23#2.
… helper 11 cases: - Map form decodes (regression — already-working path) - List form decodes (the issue Mcrich23#2 case) - Mixed forms across services in the same file - environment key absent decodes as nil - Helper: KEY=value splits at first = - Helper: only the first = splits, rest stays in value (DSN/URL values) - Helper: empty value after = decodes as empty string - Helper: bare key inherits from process env when set - Helper: bare key with no host env value decodes as empty string - Helper: empty list returns empty dict - Helper: duplicate keys — last wins
This was referenced May 4, 2026
Cyb3rDudu
added a commit
to Cyb3rDudu/Container-Compose
that referenced
this pull request
May 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Compose files using the list form of
environment:fail to parse. Reporter's case from #2:The Compose spec allows both shapes for
services.<svc>.environment:Service.swiftdecodes only the map form ([String: String]?), so the list form throwsDecodingError.typeMismatchand the whole compose file fails to load. List form is the older docker-classic style still used by Docker Registry, Sentry, GitLab, and many other official examples — comment thread on #2 has multiple users hitting it.Fix tries the map form first (no behavior change for existing users), falls back to a small parser:
KEY=valuesplits on first=(later=chars stay in the value, so DSN-stylepostgres://u:p@h/db?sslmode=requireround-trips)KEYreads fromProcessInfo.processInfo.environment[KEY], falling back to empty string when unset (Compose's "inherit from host" shorthand)Tests: 11 static cases covering both decode paths end-to-end (map form regression, list form, mixed forms across services, env key absent) plus targeted unit tests on the
parseEnvironmentListhelper (first-=split, DSN-style values, bare-key inheritance, duplicates, empty list).Fixes #2. Fixes #65.