Skip to content

Ambiguous Method Calls in Auto-Generated Test Code #3291

@rohitsinghal4u

Description

@rohitsinghal4u

Hi,

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.

PR: https://github.com/Azure/azure-rest-api-specs/pull/40714/changes

Location:

Repository: azure-rest-api-specs
Specification: KeyVault Certificates (2025-06-01-preview)
Generated test files:
GetCertificateIssuersTests.java
GetCertificateVersionsTests.java

Problem Details:
The generator creates overloaded convenience methods in the client:
// Both methods exist:

  1. getCertificateIssuers(RequestOptions requestOptions) // Low-level API
  2. getCertificateIssuers(Integer maxresults) // Convenience method

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions