Skip to content

fix(builders): reject empty target string#6679

Merged
caarlos0 merged 1 commit into
goreleaser:mainfrom
sueun-dev:fix/builders-reject-empty-target
Jun 30, 2026
Merged

fix(builders): reject empty target string#6679
caarlos0 merged 1 commit into
goreleaser:mainfrom
sueun-dev:fix/builders-reject-empty-target

Conversation

@sueun-dev

Copy link
Copy Markdown
Contributor

The rust, zig, deno, and bun builders load their valid-target lists from embedded .txt files and parse them with strings.Split(string(bts), "\n"). Those files end with a trailing newline, so the split leaves an empty string at the end of allTargets (and zig's errTargets). That makes an empty target validate as if it were a real one: isValid("") returns true for rust/deno/bun, and zig's checkTarget("") returns targetBroken instead of targetInvalid.

As a result, an empty entry in a build's targets list (for example a stray empty item in the YAML list) is silently accepted instead of failing with the usual invalid target error.

This drops empty entries when building the lists, so an empty target is rejected like any other unknown one. I added an empty target case to each builder's TestWithDefaults; 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.

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.
@pull-request-size pull-request-size Bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jun 29, 2026
@caarlos0 caarlos0 merged commit 7d602ff into goreleaser:main Jun 30, 2026
1 check passed
@caarlos0

Copy link
Copy Markdown
Member

good catch, thank you

@github-actions github-actions Bot added this to the v2.16 milestone Jun 30, 2026
@caarlos0 caarlos0 modified the milestones: v2.16, v2.17 Jul 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants