fix: close the variables namespace inside a context too - #42
Merged
Conversation
The previous commit tightened the top-level `variables` and left the same hole
one level down: contexts.*.variables was Expect::anyOf(array, null), so
`constatns:` under a context was valid config and the override silently never
applied. Same class of bug, same argument for fixing it before 0.2 rather than
after - tightening later rejects configs that load today.
before: value=[NULL], "> printf %s token " (exit 0)
after: Unexpected item 'contexts > local > variables > constatns',
did you mean 'constants'?
The context body itself stays open on purpose: a listener may read a key of its
own out of the raw config, and nothing in Sputnik reads a context beyond
`description` and `variables.constants`. Only the variables namespace is closed,
and a test pins that distinction.
Reading resolve() for this turned up a second silent no-op named in its own
comment: the secrets guard says secrets are not context-overridable "matching
dynamics" - but dynamics had no guard, so a contexts.*.variables.dynamics block
was ignored without a word. Both sections now raise the same explanatory error,
which is also why the schema accepts them: a generic unexpected-item message
would be worse than the one the resolver gives.
The guard is named assertOnlyConstantsAreContextOverridden now, since
assertNoContextLevelSecrets stopped describing what it checks.
The rule was only visible as an error message at runtime. contexts.md now says it where a reader configures an override, and secrets.md notes that the same validation applies one level down.
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.
The second half of #40. Its squash captured only the first commit - the two below were pushed to that branch moments too late, so
mainhas the top-level fix without the context-level one. Cherry-picked onto currentmain, unchanged; nothing to do on #40.The same hole one level down
#40 tightened the top-level
variablesand leftcontexts.*.variablesasExpect::anyOf(array, null). Soconstatns:under a context was still valid config, and the override silently never applied. Verified against the binary:Same argument for doing it before 0.2 as in #40: tightening later rejects configs that load today, which turns a fix into a breaking change.
The context body stays open on purpose. A listener may read a key of its own out of the raw config, and nothing in Sputnik reads a context beyond
descriptionandvariables.constants- I checked every read before closing anything. Only the variables namespace is closed, and a test pins that distinction so it does not get closed by accident later:A second silent no-op, named in its own comment
Reading
resolve()for this turned up the guard for context-level secrets, whose docblock says secrets are not context-overridable "matching dynamics" - but dynamics had no guard. So acontexts.*.variables.dynamicsblock was ignored without a word, exactly the failure mode that comment exists to prevent one key over.Both sections now raise the same explanatory error:
That is also why the schema still accepts those two keys rather than rejecting them outright: a generic unexpected-item message would be worse than the reason the resolver can give.
The guard is
assertOnlyConstantsAreContextOverridden()now, sinceassertNoContextLevelSecretshad stopped describing what it checks.Docs
contexts.mdstates the rule where a reader configures an override, instead of leaving it to be discovered as a runtime error, andsecrets.mdnotes that the same validation applies one level down.Verified
🤖 Generated with Claude Code
https://claude.ai/code/session_018CTvnzcNYmFgm2HQcm821A