You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ItemPaged[CertificateProperties] KeyVault Certificate list_properties_of_certificates does not honor the include_pending optional parameter after the first page
#38589
Open
ahsonkhan opened this issue
Nov 18, 2024
· 2 comments
But subsequent pages do not have that value set. This is done in the generated code. That means, if the include_pending param is set to true, it will not return all the certificates (including pending ones), if the pending certificate happens to be listed in a page other than the first.
fromazure.identityimportDefaultAzureCredentialfromazure.keyvault.certificatesimportCertificateClient# Pre-req: Create 25 certificates first so a page is full (either through the portal or programmatically)# Case 1: Create a certificate (either on the portal or programmatically) on the first page, and run this, right away.# Works as expected.# Case 2: Create a certificate (either on the portal or programmatically) on any subsequent page, and run this, right away.# Doesn't work as expected.credential=DefaultAzureCredential()
# TODO: Set to your own KeyVault URLcertificate_client=CertificateClient(vault_url="https://<keyvault-name>.vault.azure.net/", credential=credential)
countFalse=0print("Certificates in the key vault (includePending = false):")
certificates=certificate_client.list_properties_of_certificates()
forcertificateincertificates:
print(certificate.name)
countFalse+=1countTrue=0print("Certificates in the key vault (includePending = true):")
certificatesTrue=certificate_client.list_properties_of_certificates(include_pending=True)
forcertificateincertificatesTrue:
print(certificate.name)
countTrue+=1# Expected countFalse < countTrue in both cases, since there's a certificate pending.# Case 1: In the case where the certificate gets created on the first page:# -> countFalse < countTrue# Case 2: But, in the case where the certificate gets created on any other subsequent page:# -> countFalse = countTrueprint(f"countFalse = {countFalse} vs countTrue = {countTrue}")
The issue is pervasive across all the ItemPaged methods that follow this pattern within the KeyVault SDKs, but list_properties_of_certificates and list_deleted_certificates (along with list_role_assignments in KeyVault Administration) seem to be the only ones that have optional parameters which are settable by the SDK methods (unlike maxResults) and hence have an actual behavioral bug here.
It's possible that some other service SDKs have similar concerns here.
ahsonkhan
changed the title
ItemPaged[CertificateProperties] KeyVault Certificate GetPropertiesOfCertificates does not honor the include_pending optional parameter after the first page
ItemPaged[CertificateProperties] KeyVault Certificate list_properties_of_certificates does not honor the include_pending optional parameter after the first page
Nov 18, 2024
The call to fetch the first page sets the appropriate query parameters based on the input parameter value:
azure-sdk-for-python/sdk/keyvault/azure-keyvault-certificates/azure/keyvault/certificates/_client.py
Lines 641 to 649 in e821a49
But subsequent pages do not have that value set. This is done in the generated code. That means, if the include_pending param is set to true, it will not return all the certificates (including pending ones), if the pending certificate happens to be listed in a page other than the first.
azure-sdk-for-python/sdk/keyvault/azure-keyvault-certificates/azure/keyvault/certificates/_generated/_operations/_operations.py
Lines 784 to 816 in e821a49
Here's the swagger (not sure if this requires some fix to the swagger):
https://github.com/Azure/azure-rest-api-specs/blob/4a4acecea9901c29e19ba50f2d4cf65b20115b69/specification/keyvault/data-plane/Microsoft.KeyVault/stable/7.5/certificates.json#L30-L83
Sample repro:
The issue is pervasive across all the
ItemPaged
methods that follow this pattern within the KeyVault SDKs, butlist_properties_of_certificates
andlist_deleted_certificates
(along withlist_role_assignments
in KeyVault Administration) seem to be the only ones that have optional parameters which are settable by the SDK methods (unlike maxResults) and hence have an actual behavioral bug here.It's possible that some other service SDKs have similar concerns here.
Related issues in other languages:
Azure/azure-sdk-for-net#47202
Azure/azure-sdk-for-cpp#6235
#38589
Azure/azure-sdk-for-go#23772
Azure/azure-sdk-for-js#31803
Azure/azure-sdk-for-java#42988
The text was updated successfully, but these errors were encountered: