Skip to content

fix: compare repository names when checking the default builder in pack build - #2736

Merged
jjbustamante merged 4 commits into
buildpacks:mainfrom
RaphaelFakhri:fix/forbidden-tag-default-builder
Nov 15, 2026
Merged

jjbustamante merged 4 commits into
buildpacks:mainfrom
RaphaelFakhri:fix/forbidden-tag-default-builder

Conversation

@RaphaelFakhri

Copy link
Copy Markdown
Contributor

Summary

isForbiddenTag compared the repository of the image being built with the registry of the configured default builder (RegistryStr()), so the default builder check never matched. pack build therefore accepted an image name equal to the default builder when --builder or project.toml selected another builder, and the build overwrote the default builder image.

This change compares RepositoryStr() on both sides, as the builder, lifecycle and trusted builder checks in the same function already do, and adds a test for the default builder case.

Output

Before

$ pack config default-builder some-org/default-builder:latest
$ pack build some-org/default-builder:test --builder test --trust-builder
# the build starts

After

$ pack build some-org/default-builder:test --builder test --trust-builder
ERROR: forbidden image name: name must not match default builder image name

Documentation

  • Should this change be documented?
    • Yes, see #___
    • No

Related

Resolves #2735

…ck build

isForbiddenTag compared the repository of the image being built with the
registry of the configured default builder, so the check never matched.
As a result, pack build accepted an image name that matches the default
builder (for example when --builder or project.toml selects another
builder) and could overwrite the default builder image.

Compare the repository of both references, as the other checks in the
function already do.

Signed-off-by: Raphael Fakhri <153192858+RaphaelFakhri@users.noreply.github.com>
@RaphaelFakhri
RaphaelFakhri requested review from a team as code owners November 4, 2026 07:06
@github-actions github-actions Bot added this to the 0.41.0 milestone Nov 4, 2026
@github-actions github-actions Bot added the type/enhancement Issue that requests a new feature or improvement. label Nov 4, 2026

@ToniAdreal ToniAdreal left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I independently verified this against main (f250204) from a fresh checkout (Go 1.27.3, linux/amd64): with only the new test applied, TestBuildCommand fails exactly on the new spec (81 passed / 1 failed); with the one-line change applied, the full suite is green (82 passed / 0 failed).

The fix also matches the four sibling checks in isForbiddenTag, which all compare RepositoryStr() on both sides (build.go:440/450/461/471), so this looks like the intended comparison rather than a new semantic. The new test pins the reported scenario (default builder some-org/default-builder:latest, image some-org/default-builder:test) and asserts the exact error string.

Looks good to me.

@jjbustamante jjbustamante left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thnaks for this @RaphaelFakhri

@jjbustamante jjbustamante added type/bug Issue that reports an unexpected behaviour. and removed type/enhancement Issue that requests a new feature or improvement. labels Nov 15, 2026
@jjbustamante
jjbustamante merged commit dd03c09 into buildpacks:main Nov 15, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type/bug Issue that reports an unexpected behaviour.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pack build does not refuse an image name that matches the default builder

3 participants