Skip to content

fix(config): read OPENAI_API_KEY in the load path, not from_persisted#15

Open
flobernd wants to merge 1 commit into
profile-routingfrom
openai-key-load-path
Open

fix(config): read OPENAI_API_KEY in the load path, not from_persisted#15
flobernd wants to merge 1 commit into
profile-routingfrom
openai-key-load-path

Conversation

@flobernd

Copy link
Copy Markdown
Owner

Summary

Config::from_persisted no longer reads OPENAI_API_KEY. The per-entry seeding of keyless upstreams entries moves to the load path (from_env_and_file), so config parsing is pure and no longer ambient-environment-sensitive, while production startup behavior is unchanged. Explicit api_key values are never overridden.

Testing

Full cargo test green (742 unit tests plus all integration suites, 0 failed), cargo fmt --check clean, cargo clippy --all-targets zero warnings. New tests: a purity test asserting from_persisted ignores the env var, and an end-to-end load-path test asserting the seed still applies at startup; the existing seeding tests were adapted to the load path.

Closes local-inference-lab#34.

Notes

Stacked on local-inference-lab#36's branch; retarget or rebase once that merges.

Config::from_persisted read OPENAI_API_KEY directly inside
parse_upstreams to seed any keyless upstreams entry. That made every
caller of from_persisted ambient-environment-sensitive, including its
own unit tests: whichever value OPENAI_API_KEY happened to hold in the
process at call time silently leaked into the result, a source of test
flakiness and surprising behavior for any caller building a Config
straight from a PersistedConfig value.

Move the seeding into a new seed_upstream_api_keys_from_env step,
applied only in the load path (from_env_and_file) after
apply_env_overrides and before from_persisted. from_persisted is now a
pure function of its input; the load path's observable startup
behavior (a keyless upstreams entry inherits OPENAI_API_KEY, an
explicit api_key is never overridden) is unchanged.

Closes local-inference-lab#34
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