Skip to content

fix: preserve dotenv declaration order - #3078

Open
satya-sudo wants to merge 1 commit into
go-task:mainfrom
satya-sudo:fix/dotenv-expansion-order
Open

satya-sudo wants to merge 1 commit into
go-task:mainfrom
satya-sudo:fix/dotenv-expansion-order

Conversation

@satya-sudo

Copy link
Copy Markdown

Description

Fixes #1847
Preserve dotenv declaration order when loading global and task-level environment
files. MIT liscense is added , The existing loaders copy godotenv's plain Go map into Task's ordered
variable store, losing declaration order. This makes nested global dotenv
{{.VAR}} references resolve inconsistently between runs.

Adapt the godotenv v1.5.1 parser into an internal package backed by the existing
ordered-map dependency, Both loaders use
this reader. Dollar expansion, quotes, parse errors, optional missing files and
first-file-wins precedence remain unchanged. No new dependency is added and no
public API is introduced.

Validation:

  • go test ./...
  • golangci-lint run using the pinned v2.14.0
  • go build -o bin/task ./cmd/task and run the nested-path fixture
  • The regression test fails against the original loaders with truncated paths.
  • Regression coverage repeats the nested path and declaration-order checks
    50 times; parser tests cover syntax, quoting, multiline values, CRLF,
    duplicate keys, dollar expansion and error compatibility.

AI assistance was used to prepare tests and validation.

Checklist

  • I have read and followed the Contribution Guide.
  • I have disclosed the use of any AI-generated content in this pull request per the AI Usage Policy.
  • I fully understand the changes and have hand-written the description (No AI) of this pull request.

This branch has not been deployed

No deployments
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.

Inconsistent Variable Expansion When Using {{.VAR}} in .env Files with Nested Variables

1 participant