{"action":"created","issue":{"url":"https://api.github.com/repos/sitewhere/sitewhere/issues/524","repository_url":"https://api.github.com/repos/sitewhere/sitewhere","labels_url":"https://api.github.com/repos/sitewhere/sitewhere/issues/524/labels{/name}","comments_url":"https://api.github.com/repos/sitewhere/sitewhere/issues/524/comments","events_url":"https://api.github.com/repos/sitewhere/sitewhere/issues/524/events","html_url":"https://github.com/sitewhere/sitewhere/issues/524","id":246543516,"number":524,"title":"Deleting active assignment from device UI does not delete assignment token from device document.","user":{"login":"nmarus","id":1557166,"avatar_url":"https://avatars0.githubusercontent.com/u/1557166?v=4","gravatar_id":"","url":"https://api.github.com/users/nmarus","html_url":"https://github.com/nmarus","followers_url":"https://api.github.com/users/nmarus/followers","following_url":"https://api.github.com/users/nmarus/following{/other_user}","gists_url":"https://api.github.com/users/nmarus/gists{/gist_id}","starred_url":"https://api.github.com/users/nmarus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nmarus/subscriptions","organizations_url":"https://api.github.com/users/nmarus/orgs","repos_url":"https://api.github.com/users/nmarus/repos","events_url":"https://api.github.com/users/nmarus/events{/privacy}","received_events_url":"https://api.github.com/users/nmarus/received_events","type":"User","site_admin":false},"labels":[{"id":73618488,"url":"https://api.github.com/repos/sitewhere/sitewhere/labels/bug","name":"bug","color":"fc2929","default":true}],"state":"open","locked":false,"assignee":{"login":"derekadams","id":338921,"avatar_url":"https://avatars0.githubusercontent.com/u/338921?v=4","gravatar_id":"","url":"https://api.github.com/users/derekadams","html_url":"https://github.com/derekadams","followers_url":"https://api.github.com/users/derekadams/followers","following_url":"https://api.github.com/users/derekadams/following{/other_user}","gists_url":"https://api.github.com/users/derekadams/gists{/gist_id}","starred_url":"https://api.github.com/users/derekadams/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/derekadams/subscriptions","organizations_url":"https://api.github.com/users/derekadams/orgs","repos_url":"https://api.github.com/users/derekadams/repos","events_url":"https://api.github.com/users/derekadams/events{/privacy}","received_events_url":"https://api.github.com/users/derekadams/received_events","type":"User","site_admin":false},"assignees":[{"login":"derekadams","id":338921,"avatar_url":"https://avatars0.githubusercontent.com/u/338921?v=4","gravatar_id":"","url":"https://api.github.com/users/derekadams","html_url":"https://github.com/derekadams","followers_url":"https://api.github.com/users/derekadams/followers","following_url":"https://api.github.com/users/derekadams/following{/other_user}","gists_url":"https://api.github.com/users/derekadams/gists{/gist_id}","starred_url":"https://api.github.com/users/derekadams/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/derekadams/subscriptions","organizations_url":"https://api.github.com/users/derekadams/orgs","repos_url":"https://api.github.com/users/derekadams/repos","events_url":"https://api.github.com/users/derekadams/events{/privacy}","received_events_url":"https://api.github.com/users/derekadams/received_events","type":"User","site_admin":false}],"milestone":null,"comments":0,"created_at":"2017-07-29T20:28:29Z","updated_at":"2017-07-29T23:05:16Z","closed_at":null,"body":"While in the Web UI, under devices and within a specific device, if an active assignment is deleted, the assignment token does not get removed from the device doc and will still show \"assigned\" when looking at the full list of devices. Clicking \"Release assignment\" from there, gets the error that \"device assignment token not found.\" This prevents the device from being reassigned, or deleted.\r\n\r\nOf note, while in this state, from the API, you can successfully `get` the previously deleted assignment via `/assignments/{assignment token}`, but when attempting to delete the assignment with the corresponding delete call, the API responds with same error above.\r\n\r\nWith further investigating via mongo shell, I noticed the assignment does not exist in the Assignments collection, which was odd since I was able to get the Assignment from the API.  I also verified that the device doc was still was referencing the assignment token in the Devices collection. \r\n\r\nI was able to fix this by removing the device from the Devices collection via mongo shell and was then able to re-create and re-assign the device from the UI.\r\n\r\nUsing build: 1.11.0.20170627100515"},"comment":{"url":"https://api.github.com/repos/sitewhere/sitewhere/issues/comments/318865425","html_url":"https://github.com/sitewhere/sitewhere/issues/524#issuecomment-318865425","issue_url":"https://api.github.com/repos/sitewhere/sitewhere/issues/524","id":318865425,"user":{"login":"derekadams","id":338921,"avatar_url":"https://avatars0.githubusercontent.com/u/338921?v=4","gravatar_id":"","url":"https://api.github.com/users/derekadams","html_url":"https://github.com/derekadams","followers_url":"https://api.github.com/users/derekadams/followers","following_url":"https://api.github.com/users/derekadams/following{/other_user}","gists_url":"https://api.github.com/users/derekadams/gists{/gist_id}","starred_url":"https://api.github.com/users/derekadams/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/derekadams/subscriptions","organizations_url":"https://api.github.com/users/derekadams/orgs","repos_url":"https://api.github.com/users/derekadams/repos","events_url":"https://api.github.com/users/derekadams/events{/privacy}","received_events_url":"https://api.github.com/users/derekadams/received_events","type":"User","site_admin":false},"created_at":"2017-07-29T23:05:16Z","updated_at":"2017-07-29T23:05:16Z","body":"We have logic to prevent a device from being deleted when it's assigned, but it looks like there is no logic to prevent an active assignment from being deleted. You should only be able to delete an assignment once it has been released, so this is definitely a bug. Regarding the assignment still showing up via the REST services, this may be a case where it's not being removed from the assignment cache properly. We will double-check on that as well. A fix should be included in the 1.12 release that will be available at the end of next week. Thanks!"}}
{"actor":{"display_login":"derekadams"}}