feat: lazy validation, only resolve expressions for the active context#148
Merged
Conversation
Inactive contexts with unresolved expressions (e.g. unset env vars) no longer cause loadConfig to fail. The pipeline now structurally validates the outer config shape first, then resolves expressions and runs full Zod validation only on the active context and commands. Closes #144
margaretjgu
approved these changes
Apr 14, 2026
|
|
||
| // Step 6: build and return ResolvedConfig | ||
| const ctx = contextParsed.data | ||
| const resolved: ResolvedContext = {} |
Contributor
There was a problem hiding this comment.
lgtm! since LoadConfig now contains the same lines from resolveContext, i think we can either refactor resolveContext so loadConfig can still call it (instead of duplicating), or add a comment saying this function is no longer used by loadConfig, kept for external callers...for future maintenance if we need ot update the context in two places.
not urgent just nitpick
Contributor
Author
There was a problem hiding this comment.
Whoops sorry, got trigger happy on merging!
I'll raise a PR to fix this!
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.
Summary
loadConfigto use two-stage validation: structural first, then full validation only on the active contextStructuralConfigSchemathat validates the outer config shape (current_context, contexts keys, commands) without deeply validating context valuesPromise.all)Closes #144
Test plan
--use-contextoverride resolves only the selected context