Handle when keychain query returns an unhandled error#331
Merged
katiewasnothere merged 2 commits intoapple:mainfrom Jul 14, 2025
Merged
Conversation
3 tasks
5d67e80 to
68b7745
Compare
68b7745 to
50975f4
Compare
dcantah
reviewed
Jul 12, 2025
| authentication = try keychain.lookup(domain: host) | ||
| } catch let err as KeychainHelper.Error { | ||
| guard case .keyNotFound = err else { | ||
| throw ContainerizationError(.internalError, message: "\(String(describing: err)). Error querying keychain for \(host)") |
Member
There was a problem hiding this comment.
ContainerizationError has a cause field that you can include the original error on:
throw ContainerizationError(.internalError, message: "Error querying keychain for \(host)", cause: err)
Member
There was a problem hiding this comment.
We also don't handle any of the other ways .get() and .exists() can fail internally in .lookup(), this only catches .keyNotFound.
Contributor
Author
There was a problem hiding this comment.
We intentionally only want to catch the keyNotFound error, since we may still be able to pull/push the image in that scenario.
katiewasnothere
added a commit
to apple/containerization
that referenced
this pull request
Jul 14, 2025
This allows us to handle errors from lookup with only the keychain helper error types which simplifies the logic related apple/container#331 Signed-off-by: Kathryn Baldauf <k_baldauf@apple.com>
Signed-off-by: Kathryn Baldauf <k_baldauf@apple.com>
…uery errors Signed-off-by: Kathryn Baldauf <k_baldauf@apple.com>
b2f0e4c to
9127a8e
Compare
adityaramani
approved these changes
Jul 14, 2025
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.
Depends on apple/containerization#210
Related to #254