Repository navigation
Conversation
scopeToConfigDir joined the registry as given onto the Buildx config dir. For a registry given as a URL this produced config/https:/<host>/<scope>, and Buildx parses the first path element as the registry host, so it never finds these credentials. ECR always hits this: loginECR logs in to the proxy endpoint returned by GetAuthorizationToken, which is a URL (https://<id>.dkr.ecr.<region>.amazonaws.com), so a scoped ECR login wrote its credentials to a directory Buildx does not read, and logout looked in a different directory than login wrote to. Drop the URL scheme and trailing slashes before building the path. Assisted-By: Claude Signed-off-by: breken-ai <312387581+breken-ai@users.noreply.github.com>
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.
When
scopeis set,scopeToConfigDirjoins the registry onto the Buildx config dir exactly as it was given. If the registry is a URL, the path becomesconfig/https:/<host>/<scope>. Buildx'sparseConfigKey(util/dockerutil/dockerconfig/configprovider.go) reads the first path element as the host. It getshttps:as the host and never uses these credentials.This always happens for a scoped ECR login.
loginECRrunsdocker loginagainst theproxyEndpointfromGetAuthorizationToken, and that value is a URL (https://012345678910.dkr.ecr.eu-west-3.amazonaws.com). So this setupwrites the credentials to
~/.docker/buildx/config/https:/012345678910.dkr.ecr.eu-west-3.amazonaws.com/myapp@push. Buildx never reads that directory, so the push is not authenticated. Logout in the post step targets a different directory: it computes the path from theregistryinput, which has no scheme. The same thing happens with any registry written as a URL, such asregistry: https://ghcr.io.Fix: remove the URL scheme and any trailing slashes before building the path. Then login, logout and Buildx all use
config/<host>/<scope>. The existing checks for paths that escape the Buildx config dir still run on the result.Tests
scopeToConfigDir uses the registry host for %s(context.test.ts): covershttps://ghcr.io,https://ghcr.io/,http://localhost:5000, an ECR proxy endpoint andhttps://docker.io.loginECR writes scoped credentials to the config dir of the registry host(docker.test.ts): mocksgetRegistriesDatawith a URL proxy endpoint, checks thatDOCKER_CONFIGfordocker loginisconfig/<host>/myapp@push, and checks that it matches theconfigDirthatgetAuthListsaves for logout.Received: ".../buildx/config/https:/012345678910.dkr.ecr.eu-west-3.amazonaws.com/myapp@push". With the fix, all 86 pass.yarn lintandtsc --noEmitpass.dist/is rebuilt withyarn build, and onlyindex.cjsand its sourcemap change.AI disclosure: I found and fixed this with help from an AI assistant (Claude). I checked the change and the tests myself.
🤖 Generated with Claude Code