Repository navigation
Report each builtin's own name when it errors - #1008
Merged
joaopapereira merged 2 commits intoOct 3, 2026
Merged
joaopapereira merged 2 commits into
joaopapereira merged 2 commits into
Conversation
Two builtins in the ytt standard library were registered under a
different function's name, so a failing call named a function the user
had not called.
pkg/yttlibrary/math.go:118 registered the "mod" member as
m.newBinaryBuiltin("round", math.Mod). core.ErrWrapper
(pkg/template/core/errs.go:30) prefixes every error with f.Name(), so
math.mod(5) failed with "round: expected exactly two arguments".
math.round is a real function in the same module, so the message
pointed at the wrong call.
pkg/yttlibrary/overlay/api.go:323 returned the matcher built by
overlay.not_op as starlark.NewBuiltin("overlay.or_op", ...), copied
from OrOp directly above it. An error raised while matching under
@overlay/match by=overlay.not_op(...) was reported as overlay.or_op.
Each builtin now carries its own name. Behaviour is otherwise
unchanged. Two filetests cover the error text, one per module.
Signed-off-by: Max Freedom Pollard <[email protected]>
Signed-off-by: Max Freedom Pollard <[email protected]>
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
Two builtins in the standard library are registered under a different function's name, so when one of them fails, ytt names a function the user never called.
pkg/yttlibrary/math.go:118registers themodmember asm.newBinaryBuiltin("round", math.Mod).core.ErrWrapperprefixes every error withf.Name()(pkg/template/core/errs.go:30), somath.mod(5)fails withround: expected exactly two arguments.math.roundis a real function in the same module, so the message points at the wrong call.pkg/yttlibrary/overlay/api.go:323returns the matcher built byoverlay.not_opasstarlark.NewBuiltin("overlay.or_op", ...), copied fromOrOpdirectly above it. An error raised while matching under@overlay/match by=overlay.not_op(...)comes back asoverlay.or_op.Each builtin now carries its own name. Nothing else changes:
modstill callsmath.Modandnot_opstill negates its matcher.I checked every other
starlark.NewBuiltincall underpkg/for the same slip. These two are the only ones that name a different function.Testing
One filetest per module, both asserting the error text:
pkg/yamltemplate/filetests/ytt-library/math-mod-err.tpltestpkg/yamltemplate/filetests/ytt-library/overlay/not-op-err.tpltestWith the two source changes reverted and the new tests kept,
go test -count=1 ./pkg/yamltemplate/...fails on both, showing the old names:Local runs on macOS arm64 with Go 1.26.4, on 7 Sep 2026:
go test -count=1 ./...passes,test/e2eandtest/filetestsincluded, against ayttbinary built from this branchgofmt -l pkg/yttlibrary/math.go pkg/yttlibrary/overlay/api.goprints nothinggit diff --checkis cleanBranched from
developat6a94bf4.