[Key Vault] Added null checks for HttpResponseException.getResponse()#47801
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request fixes a NullPointerException that occurs when HttpResponseException.getResponse() returns null, which previously caused the real exception (such as authentication errors) to be hidden behind an NPE. The fix adds null checks before accessing the status code from HTTP responses across multiple Key Vault client libraries.
Changes:
- Added null checks for
HttpResponseException.getResponse()in exception mapping methods and polling operations - Ensures that when the response is null, the original exception is returned unchanged or appropriate fallback behavior is applied
- Affects secrets, keys, certificates, and administration client libraries
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| SecretClient.java | Added null checks in delete and recover polling operations before checking 404 status |
| SecretAsyncClient.java | Added null checks in exception mappers (set, get, restore) and polling operations |
| CryptographyUtils.java | Added null check in isThrowableRetryable with early return false when response is null |
| CryptographyClientImpl.java | Added null check in error mapping for get key operation |
| KeyClient.java | Added null checks in delete and recover polling operations before checking 404 status |
| KeyAsyncClient.java | Added null checks in exception mappers (create, get, restore) and polling operations |
| CertificateClient.java | Added null checks in delete and recover polling operations before checking 404 status |
| CertificateAsyncClient.java | Added null checks in multiple exception mappers and polling operations |
| KeyVaultAdministrationUtil.java | Added null check in swallowExceptionForStatusCodeSync utility method |
samvaity
approved these changes
Jan 27, 2026
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.
Description
Fixes: #47647
Adds null checks for calls to
HttpResponseException.getResponse()in Key Vault clients for better diagnosability.All SDK Contribution checklist:
General Guidelines and Best Practices
Testing Guidelines