azure-sdk-for-java icon indicating copy to clipboard operation
azure-sdk-for-java copied to clipboard

[BUG] Key Vault ResourceModifiedException: Status Code 400

Open saragluna opened this issue 1 year ago • 0 comments

Describe the bug We ran into this KV exception when running ITs with libs in the buildFromSource step. We managed to create a minimal project to reproduce the issue. https://github.com/saragluna/kv-it-issue.

Exception or Stack Trace

Exception in thread "main" com.azure.core.exception.ResourceModifiedException: Status code 400, "{"error":{"code":"BadParameter","message":"Property  has invalid value\r\n"}}"
	at com.azure.core.implementation.http.rest.RestProxyBase.instantiateUnexpectedException(RestProxyBase.java:366)
	at com.azure.core.implementation.http.rest.SyncRestProxy.ensureExpectedStatus(SyncRestProxy.java:121)
	at com.azure.core.implementation.http.rest.SyncRestProxy.handleRestReturnType(SyncRestProxy.java:206)
	at com.azure.core.implementation.http.rest.SyncRestProxy.invoke(SyncRestProxy.java:76)
	at com.azure.core.implementation.http.rest.RestProxyBase.invoke(RestProxyBase.java:110)
	at com.azure.core.http.rest.RestProxy.invoke(RestProxy.java:95)
	at com.sun.proxy.$Proxy3.setSecret(Unknown Source)
	at com.azure.security.keyvault.secrets.implementation.SecretClientImpl.setSecretWithResponse(SecretClientImpl.java:497)
	at com.azure.security.keyvault.secrets.SecretClient.setSecretWithResponse(SecretClient.java:147)
	at com.azure.security.keyvault.secrets.SecretClient.setSecret(SecretClient.java:118)
	at com.example.demo.DemoApplication.main(DemoApplication.java:19)

To Reproduce https://github.com/saragluna/kv-it-issue

Code Snippet

private static final String NAME = "sample-key";
private static final String VALUE = "sample-value";

SecretClient client = new SecretClientBuilder()
		.vaultUrl("XXX")
		.credential(new DefaultAzureCredentialBuilder().build())
		.buildClient();

client.setSecret(NAME, VALUE);
KeyVaultSecret secret = client.getSecret(NAME);
System.out.println(secret.getValue());

Expected behavior The code can work fine.

Screenshots image

Setup (please complete the following information):

  • OS: [MacOS]
  • IDE: [IntelliJ]
  • Library/Libraries: [azure-security-keyvault-secrets:4.5.0-beta.1]
  • Java version: [8]
  • App Server/Environment: [N/A]
  • Frameworks: [N/A]

If you suspect a dependency version mismatch (e.g. you see NoClassDefFoundError, NoSuchMethodError or similar), please check out Troubleshoot dependency version conflict article first. If it doesn't provide solution for the problem, please provide:

  • verbose dependency tree (mvn dependency:tree -Dverbose)
  • exception message, full stack trace, and any available logs

Additional context N/A

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

  • [x] Bug Description Added
  • [x] Repro Steps Added
  • [x] Setup information Added

saragluna avatar Aug 12 '22 11:08 saragluna