fix(builders): reject empty target string#6679
Merged
caarlos0 merged 1 commit intoJun 30, 2026
Merged
Conversation
The embedded target lists end with a trailing newline, so
strings.Split(..., "\n") leaves an empty string in allTargets (and in
zig's errTargets). That made an empty target validate as a real target:
isValid("") returned true for rust, deno and bun, and zig's
checkTarget("") returned targetBroken instead of targetInvalid.
As a result an empty/blank entry in a build's targets list was silently
accepted instead of failing with the usual "invalid target" error.
Drop empty entries when building the target lists so an empty target is
rejected like any other unknown one.
Member
|
good catch, thank you |
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 rust, zig, deno, and bun builders load their valid-target lists from embedded
.txtfiles and parse them withstrings.Split(string(bts), "\n"). Those files end with a trailing newline, so the split leaves an empty string at the end ofallTargets(and zig'serrTargets). That makes an empty target validate as if it were a real one:isValid("")returns true for rust/deno/bun, and zig'scheckTarget("")returnstargetBrokeninstead oftargetInvalid.As a result, an empty entry in a build's
targetslist (for example a stray empty item in the YAML list) is silently accepted instead of failing with the usualinvalid targeterror.This drops empty entries when building the lists, so an empty target is rejected like any other unknown one. I added an
empty targetcase to each builder'sTestWithDefaults; it fails before the change and passes after.AI disclosure: I used AI assistance while writing this change, and I've reviewed and understand all of it.