Skip to content

[Mgmt Generator] BuildGetChildResourceMethods does not pass path parameters for nested child resources #57252

@haiyuazhang

Description

@haiyuazhang

Bug Description

ResourceClientProvider.BuildGetChildResourceMethods() generates collection getter and Get/GetAsync methods for child resources on a parent resource class. When child resources have extra path parameters between the parent and child resource (e.g., nestedResourceTypeFirst), these parameters are:

  1. Not passed to the collection constructor in the getter method body (line 480)
  2. Not included in the Get/GetAsync method signatures (line 504-510)
  3. Not forwarded when calling the collection getter from Get/GetAsync methods (line 515)

Impact

This affects any ARM resource with nested children that have intermediate path segments. For example, ProviderHub has:

  • ResourceTypeRegistration (parent)
    • NestedResourceTypeFirstSku (child, needs nestedResourceTypeFirst path param)
    • NestedResourceTypeSecondSku (child, needs nestedResourceTypeFirst + nestedResourceTypeSecond)
    • NestedResourceTypeThirdSku (child, needs 3 path params)

The generated accessor methods either compile with errors or are suppressed via CodeGenSuppress.

Root Cause

File: ResourceClientProvider.cs in Azure.Generator.Management

Collection getter (line 480):
\\csharp
// Only passes client and Id, ignores path parameters from signature
New.Instance(childResource.ResourceCollection.Type, client, thisResource.Id())
\\

Get method signature (line 504-510): Only includes collectionSignature.Parameters (e.g., sku, cancellationToken) but not the path parameters from the collection getter's signature.

Get method body (line 515): Calls thisResource.Invoke(signature.Name) without passing path parameter arguments.

Fix

See PR linked to this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    CodeGenIssues that relate to code generationMgmtThis issue is related to a management package.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions