Platform caching bug - deleteChildDevices

@gausnes I ran into this issue today while developing a SmartApp Service Manager that creates and delete child devices.

The basic flow of the installed method is

  1. Find new devices and install them using addChildDevice
  2. Find dead/orphaned devices and remove them using deleteChildDevice
  3. Get a list of child devices using getChildDevices
  4. Subscribe to the device event using subscribe(getChildDevices(), "event", handler)

There appears to be some caching bug going on with deleteChildDevice. After calling deleteChildDevice, when I call getChildDevices, the recently deleted device STILL shows up in the list of child devices.

Then when the SmartApp calls subscribe with getChildDevices() it thows an error:

bb59d7ee-ac6f-40d2-a68f-c8efb02c35ff 10:43:42 PM: error org.springframework.security.access.AccessDeniedException: Access is denied @ line 676

It basically craps out on the subscribe command because getChildDevices() is returning a deleted device in it’s list.

I confirmed this with 2 tests:

  1. If I don’t do subscribe it goes through fine and getChildDevice returns the correct list of devices
  2. If I don’t do a call to deleteChildDevice it also goes through fine and subscribe succeeds

Any idea why deleteChildDevice followed by a getChildDevices and a subscribe command is causing the platform to cache and return the deleted child device?

1 Like

© 2019 SmartThings, Inc. All Rights Reserved. Terms of Use | Privacy Policy

SmartThings; SmartApps®; Physical Graph; Hello, Home; and Hello, Smart Home are all trademarks of the SmartThings, Inc.