Gracefully handle credential store errors in get_all_credentials#3390
Open
Krishnachaitanyakc wants to merge 1 commit intodocker:mainfrom
Open
Gracefully handle credential store errors in get_all_credentials#3390Krishnachaitanyakc wants to merge 1 commit intodocker:mainfrom
Krishnachaitanyakc wants to merge 1 commit intodocker:mainfrom
Conversation
When `get_all_credentials` iterates over credential stores (both the default `credsStore` and per-registry `credHelpers`), a `StoreError` from any single store would propagate as a `DockerException` and abort the entire operation. This caused image builds to fail even when the failing credentials were not needed (e.g., expired gcloud auth tokens when building a publicly accessible image). This change wraps each call to `_resolve_authconfig_credstore` inside `get_all_credentials` with a try/except that catches `DockerException`, logs a warning, and skips the failing entry instead of propagating the error. All other valid credentials are still collected and returned. Fixes docker#3379
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
Fixes #3379
When
get_all_credentials()iterates over credential stores (both the defaultcredsStoreand per-registrycredHelpers), aStoreErrorfrom any single store propagates as aDockerExceptionand aborts the entire operation. This causes image builds to fail even when the failing credentials are not required — for example, when expired gcloud auth tokens exist in the local Docker config but the image being built only uses publicly accessible base images.This change wraps each call to
_resolve_authconfig_credstoreinsideget_all_credentialswith a try/except that:DockerException(which wraps the underlyingStoreError)All other valid credentials are still collected and returned as before.
Changes
docker/auth.py: ModifiedAuthConfig.get_all_credentials()to catcherrors.DockerExceptionper-entry in both thecredsStoreloop and thecredHelpersloop, logging a warning and continuing instead of propagating the error.tests/unit/auth_test.py: Added two new tests:test_get_all_credentials_credstore_error_skipped— verifies that a failingcredHelperentry is skipped while valid entries from the default store are still returned.test_get_all_credentials_default_store_error_skipped— verifies that a failing entry in the defaultcredsStoreis skipped while other valid entries from the same store are still returned.FailingStoreandPartiallyFailingStoretest helper classes.Test plan
tests/unit/auth_test.pycontinue to pass (58/58)credsStoreandcredHelpersfailure scenariosconfig.jsonwith a credential helper that fails (e.g., expiredgcloudauth), then runclient.images.build()for a public image and confirm it no longer raises