Skip to content

refactor(secrets): state the .env layering once, and let callers read it - #5567

Open
aodhanroche wants to merge 1 commit into
Aodhan/260901/diagnostics-1-loggingfrom
Aodhan/260901/diagnostics-2-env-merge
Open

aodhanroche wants to merge 1 commit into
Aodhan/260901/diagnostics-1-loggingfrom
Aodhan/260901/diagnostics-2-env-merge

Conversation

@aodhanroche

@aodhanroche aodhanroche commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

Issue

The .env layering (workspace beats global) was buried in a private method. The diagnostics report later in this stack reads the same two files to say which file each key came from — a second copy of that merge means the report could go quietly wrong about which file to look at.

Fix

Pull the merge into a module-level merge_env_file_values, split the per-file read into _read_env_file, and make read_merged_env_files public so the report can resolve the same values.

No behaviour change. Gets its first caller in #5571.

🤖 Generated with Claude Code

`get_secret` documents that a workspace `.env` beats the global one, but the
merge expressing that lived inside `_read_merged_env_files` as a private
detail. The diagnostics report added later in this stack reads the same two
files itself, so that it can say which file each key came from -- and a second
hand-written copy of the merge means a later change to the layering could be
applied to secret resolution and not to the report of it, leaving the report
quietly wrong about which file a support engineer should be looking at.

Extracts the merge into a module-level `merge_env_file_values`, splits the
per-file read into `_read_env_file`, and renames `_read_merged_env_files` to
`read_merged_env_files` so the report can resolve the same values this manager
resolves from -- which is what lets it scrub them out of log text rather than
guess at them.

No behaviour change: workspace still wins, empty values are still kept as
empty strings, missing files are still skipped, and `None` from `dotenv_values`
is still filtered so callers keep a `dict[str, str]`.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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