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
{{ message }}
This repository was archived by the owner on Jul 6, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Jul 6, 2026. It is now read-only.
Ambiguous Method Calls in Auto-Generated Test Code #3291
I'm reporting a bug in the auto-generated test files that prevents compilation when multiple convenience method overloads exist.
Issue Description:
When the generator creates test files for operations with pagination parameters, it generates method calls with null parameters that result in ambiguous method call errors during compilation.
But the generated test calls them with null:
PagedIterable response = keyVaultClient.getCertificateIssuers(null);
This creates an ambiguous method reference compilation error because null can match either parameter type.
Expected Behavior:
Generated tests should either:
Use the parameterless convenience method overload (if available), or
Pass the correct typed parameter, or
Explicitly cast the null to avoid ambiguity
Reproducibility:
Generate Java SDK from KeyVault Certificates specification (API version 2025-06-01-preview) and run mvn test on the generated project.
I think "Explicitly cast the null to avoid ambiguity" likely be the easiest solution.
The "Pass the correct typed parameter" didn't happen, likely because that the JSON example in specs repo does not have this Integer parameter (otherwise, emitter would use that value).
Meantime, before emitter fix, you can delete the tests that fails compilation. They are mostly for reference when you plan to write LIVE tests.
[ERROR] /C:/github/azure-sdk-for-java/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/models/CertificateOperation.java:[133,29] incompatible types: com.azure.security.keyvault.certificates.implementation.models.KeyVaultErrorError cannot be converted to com.azure.security.keyvault.certificates.models.CertificateOperationError
then tons of error in tests/samples.
If that many test compilation failure occurs to you as well (likely due to code customization). You may prefer to turn them off at tspconfig.yaml
Thank you Weidong Xu (@weidongxu-microsoft) for the prompt response. I am compiling sdk directly from the path: azure-rest-api-specs\specification\keyvault\Security.KeyVault.Certificates\tsp-output\sdk\keyvault\azure-security-keyvault-certificates
with mvn clean compile
I don't see any compilation error.
Is it ok to make generated-tests : false and update the PR?
Just curious to know how the SDK code will work in the production by which generator creates, if it has a compilation error?
The SDK code is not incorrect. 2 methods have different method signature.
The ambiguous is on the code used in test. When written as getCertificateIssuers(null) compiler does not know which method to call. User probably would just write getCertificateIssuers(), if they want to do same.
Activity
weidongxu-microsoft commentedon Feb 25, 2026
Thanks ROHIT SINGHAL (@rohitsinghal4u) for the report and thoughtful suggestions!
I think "Explicitly cast the null to avoid ambiguity" likely be the easiest solution.
The "Pass the correct typed parameter" didn't happen, likely because that the JSON example in specs repo does not have this Integer parameter (otherwise, emitter would use that value).
Meantime, before emitter fix, you can delete the tests that fails compilation. They are mostly for reference when you plan to write LIVE tests.
weidongxu-microsoft commentedon Feb 25, 2026
BTW, when I test on regen of SHA at Azure/azure-rest-api-specs#40714
on sdk/keyvault/azure-security-keyvault-certificates
I would get a compilation error on source
then tons of error in tests/samples.
If that many test compilation failure occurs to you as well (likely due to code customization). You may prefer to turn them off at tspconfig.yaml
rohitsinghal4u commentedon Feb 25, 2026
Thank you Weidong Xu (@weidongxu-microsoft) for the prompt response. I am compiling sdk directly from the path:
azure-rest-api-specs\specification\keyvault\Security.KeyVault.Certificates\tsp-output\sdk\keyvault\azure-security-keyvault-certificateswith
mvn clean compileI don't see any compilation error.
Is it ok to make generated-tests : false and update the PR?
Just curious to know how the SDK code will work in the production by which generator creates, if it has a compilation error?
weidongxu-microsoft commentedon Feb 25, 2026
Yeah, feel free to do
generate-tests: falseThe SDK code is not incorrect. 2 methods have different method signature.
The ambiguous is on the code used in test. When written as
getCertificateIssuers(null)compiler does not know which method to call. User probably would just writegetCertificateIssuers(), if they want to do same.