fix(varlock): preserve typed builtin vars referenced from root decorators#790
Merged
Conversation
…tors Builtin vars like VARLOCK_IS_CI declare a type (boolean), but when registered early via a root-decorator reference (e.g. @import/@initOp args), the finishLoad process() pass recomputed the type and defaulted it back to 'string', stringifying false -> "false". That made not()/if() treat it as a truthy string. The builtin resolver now advertises its declared type via inferredType so config-item type inference preserves it.
Contributor
|
The changes in this PR will be included in the next version bump.
|
commit: |
philmillman
approved these changes
Jun 16, 2026
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.


What
Typed builtin vars (e.g.
VARLOCK_IS_CI, which is declaredboolean) were being stringified to"false"/"true"when referenced from a root decorator argument such as@import(enabled=...)or a plugin's@initOp(...). Because a non-empty string is truthy, this silently broke boolean logic — e.g.not($VARLOCK_IS_CI)evaluated tofalseeven when not in CI.Why
registerBuiltinVarsets the builtin item'sdataTypecorrectly, but only in the "create from scratch" branch, relying on thefinishLoadloop not revisiting the new key. When a builtin is registered early (during root-decorator processing), the item later does get aprocess()call — and since the builtin's resolver had noinferredTypeand the item has no@typedecorator, type inference defaulted it back tostring, coercing the boolean to a string.The fix: the builtin's resolver now advertises its declared type via
inferredType, so config-item type inference preserves it. One-line change inregisterBuiltinVar.Referencing the same builtin from a normal item value already worked; this only affected the early/root-decorator registration path.
Tests
Added regression tests in
builtin-vars.test.tscovering a boolean builtin referenced from a root decorator (@import(enabled=not($VARLOCK_IS_CI))) in both CI and non-CI — verified they fail without the fix and pass with it. Full env-graph suite (482 tests) green.