Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Set secret operation of the Key Vault Secrets Client overrides the content type of the secret with application/json #37019

Closed
3 tasks done
nagyesta opened this issue Oct 1, 2023 · 1 comment · Fixed by #37020
Assignees
Labels
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. KeyVault needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that

Comments

@nagyesta
Copy link
Contributor

nagyesta commented Oct 1, 2023

Describe the bug
The Key Vault Secrets Client sets or overrides the content type of the secret with application/json. This means, that even if the caller specified the content type of the secret, the created secret in the Key Vault will have application/json persisted.

Exception or Stack Trace
N/A

To Reproduce
Run the following test:

        DefaultAzureCredential credentials = new DefaultAzureCredentialBuilder().build();
        SecretClient secretClient = new SecretClientBuilder().vaultUrl(KEY_VAULT_URL)
                .credential(credentials)
                .buildClient();

        final KeyVaultSecret secretOptions = new KeyVaultSecret("plain-text", LOREM_IPSUM);
        secretOptions.getProperties().setContentType(TEXT_PLAIN);
        KeyVaultSecret result = secretClient.setSecret(secretOptions);

        assertThat(result.getProperties().getContentType()).isEqualTo(TEXT_PLAIN);

Code Snippet
The content type is set in the following locations:

The contentType parameter is always getting applciation/json as value due to these lines:

Expected behavior
When the contentType is set in the secret properties object, then it is persisted as-is, the test in the "To Reproduce" section passes.

Screenshots
N/A

Setup (please complete the following information):

  • OS: Any
  • IDE: Any
  • Library/Libraries: com.azure:azure-security-keyvault-secrets:4.7.0
  • Java version: Any
  • App Server/Environment: Any
  • Frameworks: Any

Additional context
The bug was introduced in 4.7.0, as the same test passes with 4.6.x or previous versions of the client.

Information Checklist
Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report

  • Bug Description Added
  • Repro Steps Added
  • Setup information Added
@github-actions github-actions bot added Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. KeyVault needs-team-triage Workflow: This issue needs the team to triage. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Oct 1, 2023
nagyesta added a commit to nagyesta/azure-sdk-for-java that referenced this issue Oct 1, 2023
…the content type of the secret with application/json

- Fixes sync and async implementations to use the contentType value set by the caller in the payload
- Adds entry to changelog

Resolves Azure#37019

Signed-off-by: Esta Nagy <[email protected]>
nagyesta added a commit to nagyesta/azure-sdk-for-java that referenced this issue Oct 1, 2023
…the content type of the secret with application/json

- Removes default contentType value when the properties are not defined

Resolves Azure#37019

Signed-off-by: Esta Nagy <[email protected]>
@vcolin7
Copy link
Member

vcolin7 commented Oct 3, 2023

Hi @nagyesta, thanks for reporting this and even more for creating a PR that addresses the issue, we love receiving contributions from the community. I will review it and provide any relevant feedback before EOD. I'm sure that if we can get this merged before the end of the week we can include it in next week's release :)

@alzimmermsft alzimmermsft removed the needs-team-triage Workflow: This issue needs the team to triage. label Oct 4, 2023
@github-actions github-actions bot added the needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team label Oct 4, 2023
vcolin7 added a commit that referenced this issue Oct 4, 2023
…the content type of the secret with application/json (#37020)

* [BUG] Set secret operation of the Key Vault Secrets Client overrides the content type of the secret with application/json
- Fixes sync and async implementations to use the contentType value set by the caller in the payload
- Adds entry to changelog

Resolves #37019

Signed-off-by: Esta Nagy <[email protected]>

* [BUG] Set secret operation of the Key Vault Secrets Client overrides the content type of the secret with application/json
- Removes default contentType value when the properties are not defined

Resolves #37019

Signed-off-by: Esta Nagy <[email protected]>

* Added changes missing setSecret and updateSecret methods.

* Updated tests.

* Added missing fix for updateSecretPropertiesWithResponse() methods in sync and async clients.

* Updated test recordings.

* Removed unused imports.

---------

Signed-off-by: Esta Nagy <[email protected]>
Co-authored-by: Victor Colin Amador <[email protected]>
@github-actions github-actions bot locked and limited conversation to collaborators Jan 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. KeyVault needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that
Projects
Archived in project
3 participants