Memory corruption (?) when trying to create blend shapes and skeleton animation prims

The attached extension code works once, but when trying to run it a second time it starts talking about “invalid prims”. Exiting and restarting USD Composer allows me to run it again, once. The file created seems to be all working if I save it. It feels like something being done in this extension script is causing a memory corruption or similar. Restarting USD Composer cleans things up.

To run it, create an extension and drop this in its place. Then create a new empty stage, click the button on the left to create a new SkeRoot/Skeleton with children of eastWindAnimation, westWindAnimation, southWindAnimation, northWindAnimation, noWindAnimation, and testWindAnimation the default turned on, so you can hit play and see the animation).

Then drag a model (e.g. from NVIDIA Assets, for a tree or similar to under the SkelRoot node, then click the button on the right. It should add blendshapes to the Mesh layers. Hitting play should make the object sway backwards and forwards. I normally have to save the stage and reopen it before the animation starts working. (10.4 KB)

If I try to repeat, I see errors on the console like

2023-07-23 07:59:55  [Error] [omni.ui.python] TypeError: cannot convert UsdSkel.Animation(Usd.Prim(</World/SkelRoot/Skeleton/testWindAnimation>)) to TfType; has that type been defined as a TfType?
2023-07-23 07:59:55  [Error] [omni.ui.python] 
2023-07-23 07:59:55  [Error] [omni.ui.python] At:
2023-07-23 07:59:55  [Error] [omni.ui.python]   d:/omniverse/pkg/create-2023.1.1/extscache/omni.anim.retarget.ui-105.0.9+105.0/omni/anim/retarget/ui/scripts/ on_new_payload
2023-07-23 07:59:55  [Error] [omni.ui.python]   d:/omniverse/pkg/create-2023.1.1/extscache/ _rebuild_window
2023-07-23 07:59:55  [Error] [omni.ui.python]