rubrikinc / rubrik-powershell-sdk

The Rubrik Security Cloud SDK
https://www.powershellgallery.com/packages/RubrikSecurityCloud
MIT License
7 stars 9 forks source link

Get-RscType -InitialProperties fails to init more than one nested property #112

Open rynardtspies opened 1 month ago

rynardtspies commented 1 month ago

Issue Description

When using Get-RscType to initialize properties of an object, if multiple nested properties are requested for a nested type, only the first property of the nested property tree is initialized. Subsequent properties return a null reference exception.

Steps to Reproduce

  1. Initialize properties with a single nested property:

    $fields = Get-RscType -Name VsphereVm -InitialProperties @("id", "name", "vsphereVirtualDisks.nodes.Fid")
    $fields.VsphereVirtualDisks.Nodes[0]

    Output:

    CdmId                :
    CdmVersion           :
    ClusterUuid          :
    DatastoreFid         :
    DeviceKey            :
    ExcludeFromSnapshots :
    Fid                  : FETCH
    FileName             :
    Size                 :
    VirtualMachineId     :
    Datastore            :
  2. Initialize properties with another single nested property:

    $fields = Get-RscType -Name VsphereVm -InitialProperties @("id", "name", "vsphereVirtualDisks.nodes.FileName")
    $fields.VsphereVirtualDisks.Nodes[0]

    Output:

    CdmId                :
    CdmVersion           :
    ClusterUuid          :
    DatastoreFid         :
    DeviceKey            :
    ExcludeFromSnapshots :
    Fid                  :
    FileName             : FETCH
    Size                 :
    VirtualMachineId     :
    Datastore            :
  3. Initialize properties with multiple nested properties:

    $fields = Get-RscType -Name VsphereVm -InitialProperties @("id", "name", "vsphereVirtualDisks.nodes.FileName", "vsphereVirtualDisks.nodes.Fid")

    Output:

    Get-RscType: Object reference not set to an instance of an object.
    $fields.VsphereVirtualDisks.Nodes[0]
    CdmId                :
    CdmVersion           :
    ClusterUuid          :
    DatastoreFid         :
    DeviceKey            :
    ExcludeFromSnapshots :
    Fid                  :
    FileName             : FETCH
    Size                 :
    VirtualMachineId     :
    Datastore            :

Expected Behavior

Both vsphereVirtualDisks.nodes.FileName and vsphereVirtualDisks.nodes.Fid should be initialized without causing a null reference exception.

Actual Behavior

Only the first property (FileName or Fid) is initialized, and attempting to initialize multiple nested properties results in a null reference exception.