Skip to content

[Key Vault] Added null checks for HttpResponseException.getResponse()#47801

Merged
vcolin7 merged 3 commits into
mainfrom
keyvault/add-exception-null-checks
Jan 27, 2026
Merged

[Key Vault] Added null checks for HttpResponseException.getResponse()#47801
vcolin7 merged 3 commits into
mainfrom
keyvault/add-exception-null-checks

Conversation

@vcolin7

@vcolin7 vcolin7 commented Jan 24, 2026

Copy link
Copy Markdown
Member

Description

Fixes: #47647

Adds null checks for calls to HttpResponseException.getResponse() in Key Vault clients for better diagnosability.

All SDK Contribution checklist:

  • The pull request does not introduce [breaking changes]
  • CHANGELOG is updated for new features, bug fixes or other significant changes.
  • I have read the contribution guidelines.

General Guidelines and Best Practices

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.

Testing Guidelines

  • Pull request includes test coverage for the included changes.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

@github-project-automation github-project-automation Bot moved this from Untriaged to In Progress in Azure SDK for Key Vault Jan 27, 2026
@vcolin7 vcolin7 merged commit b47a305 into main Jan 27, 2026
18 checks passed
@github-project-automation github-project-automation Bot moved this from In Progress to Done in Azure SDK for Key Vault Jan 27, 2026
@vcolin7 vcolin7 deleted the keyvault/add-exception-null-checks branch January 27, 2026 21:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[BUG] Azure KeyVault - SecretAsyncClient NPE hides real exception.

3 participants