Summary
Expression resolution currently runs eagerly across all contexts in the config, not just the active one. This means if an inactive context references an unset environment variable, the CLI will fail even though that context isn't being used.
Example
current_context: local
contexts:
local:
elasticsearch:
auth:
api_key: $(env:LOCAL_KEY)
staging:
elasticsearch:
auth:
api_key: $(env:STAGING_KEY)
Running with current_context: local will fail if STAGING_KEY is unset, because all expressions are resolved before Zod validation.
Proposed Solution
Split validation into two stages:
- Structural validation of the outer config shape (all contexts, but without resolving expressions)
- Full validation of only the active context after expression resolution
This requires restructuring the validation pipeline so that Zod doesn't reject unresolved expressions (like $(env:X)) as invalid values during the first pass.
Context
Discussion from #143 between @MattDevy and @JoshMock.
Summary
Expression resolution currently runs eagerly across all contexts in the config, not just the active one. This means if an inactive context references an unset environment variable, the CLI will fail even though that context isn't being used.
Example
Running with
current_context: localwill fail ifSTAGING_KEYis unset, because all expressions are resolved before Zod validation.Proposed Solution
Split validation into two stages:
This requires restructuring the validation pipeline so that Zod doesn't reject unresolved expressions (like
$(env:X)) as invalid values during the first pass.Context
Discussion from #143 between @MattDevy and @JoshMock.