vmware / govmomi

Go library for the VMware vSphere API
Apache License 2.0
2.32k stars 913 forks source link

[BUG] Panic when updating vcsim map with partial updates to a field #3349

Closed brakthehack closed 9 months ago

brakthehack commented 9 months ago

Describe the bug Prior to a recent change, we previously were able to trigger property collector notifications for singular items in a list by specifying the listed indexed by item key. One example of this is waiting for updates on specific VC extensions. E.g. extensionList["my-extension"].

Now when we try to perform an update via the simulator.Map.Update API while supplying a field along with an extension key, we panic.

To Reproduce Steps to reproduce the behavior:

Attempt to perform incremental property changes by specifying a key to a list.

type ExtensionManager struct {
    mo.ExtensionManager

    extensions []types.Extension
}
...

em := ExtensionManager{}

simulator.Map.Update(em, []types.PropertyChange{
    {Op: types.PropertyChangeOpAdd, Name: `extensionList["` + newExtension.Key + `"]`, Val: newExtension},
})

Expected behavior The underlying list shouldn't be changed, but a property collector update should be fired on the specific newExtension key.

Affected version All versions as of a03f4735570027d2e6e2bc9cb7584a0af19f9353q are effected.

Screenshots/Debug Output If applicable, add screenshots or debug output to help explain your problem.

Additional context Add any other context about the problem here.