Unable to register set of devices under a new application due to "duplicate_identifiers"

Due to infrastructure issues, I needed to transfer a set of 405 devices from one application to another. I used API to remove the devices from the original application called iptec-aws-integration to be able to reregister them in the new one. I called the following API endpoint:

requests.delete(f"{base_path}/applications/{application_id}/devices/iptec-{device_eui}-device", headers=headers)

All devices have been deleted from the application, so then I deleted the application as well. But now I am not able to register a single device due to the following error:

{
  "code": 6,
  "message": "error:pkg/networkserver/redis:duplicate_identifiers (duplicate identifiers)",
  "details": [
    {
      "@type": "type.googleapis.com/ttn.lorawan.v3.ErrorDetails",
      "namespace": "pkg/networkserver/redis",
      "name": "duplicate_identifiers",
      "message_format": "duplicate identifiers",
      "correlation_id": "bdf924d5456a47e8a40a87fd9b25e1cd",
      "code": 6
    }
  ]
}

Then I tried to call also:

requests.delete(f"{base_path}/ns/applications/{application_id}/devices/iptec-{device_eui}-device", headers=headers)
requests.delete(f"{base_path}/js/applications/{application_id}/devices/iptec-{device_eui}-device", headers=headers)
requests.delete(f"{base_path}/as/applications/{application_id}/devices/iptec-{device_eui}-device", headers=headers)

but now I don’t have access to the application anymore. Now I know I should not go this way, but it happened and now I really need some help from you guys because the IoT devices are already installed in the terrain and I need to connect them into the cloud again with the same combination of DevEUI and JoinEUI. I have also a list of all devices with their original identifiers.

This isn’t trivial and will take time to figure. Can you review:

https://www.thethingsindustries.com/docs/reference/api/end_device/

and comment again after you’ve done the id server delete too.

Or try the CLI which does it all for you - it may be able to clear out the bits that are left.

If those don’t work, then you will have to remap your identifiers over.

As you are creating a new OTAA session your devices will be offline until they do a link check. So you may want to look at when that will happen and plan accordingly - you may have a few days to get things in order.

@descartes Thank you for your reply! I was following this API reference and unfortunately deleted the devices only from the EndDeviceRegistry. After that, I deleted the application from the console (because no devices were there left), but I didn’t think through and forgot to delete them from the NsEndDeviceRegistry, AsEndDeviceRegistry and JsEndDeviceRegistry as well. So now, I would really love to finish the job, but I lost permission to the application because I deleted it (from the perspective of the system, hid it).

I think you will have to remap your identifiers in your backend.

So it is not possible to ask some admin to restore the application as described here: ttn-lw-cli applications restore | The Things Stack for LoRaWAN? That would really help me to finish the cleaning.

That’s a command you can run yourself, why haven’t you tried?

Forum moderators are not admin staff, just volunteers with (very) few additional privileges on the forum. The forum is meant for users to help users by answering questions and discussing TTN and LoRaWAN related concepts. It is not a support channel for TTI. If you need attention from TTI you can try Slack.

@descartes I tried, but unfortunately, when I found this command, it was too late :frowning:

WARN	Finished unary call	{"duration": 0.0538, "error": "error:pkg/identityserver:restore_window_expired (this entity can no longer be restored)", "error_correlation_id": "2636833d433f4866b1ebb3af865b5962", "error_name": "restore_window_expired", "error_namespace": "pkg/identityserver", "grpc.method": "Restore", "grpc.service": "ttn.lorawan.v3.ApplicationRegistry", "grpc_code": "FailedPrecondition", "namespace": "grpc", "request_id": "fbffd205-bca8-4f78-ac25-97cd87254bc8"}

@kersing Thanks for letting me know, I didn’t know that. I will try Slack.

Okay, so let me repeat the problem as I understand it:

  • You had 405 end devices registered in application iptec-aws-integration
  • You deleted these 405 end devices from the EndDeviceRegistry (Identity Server / IS), but not from the NsEndDeviceRegistry (Network Server / NS), AsEndDeviceRegistry (Application Server / AS) or JsEndDeviceRegistry (Join Server / JS)
  • You then deleted your application iptec-aws-integration
  • You are now unable to register your end devices in the new application, because the NS, AS and JS refuse to do so, because the end devices still exist.
  • You are now unable to delete those end devices from the NS, AS and JS, because you no longer have rights on your deleted application.
  • You are now unable to restore your deleted application, because the restore window has expired.

Is this summary correct?

Yes, that’s absolutely correct! And I would like to apologize for my stupid mistake because I should make a double check before a deleted the application and lost the permissions.

Okay. I just restored your deleted application.
This should make the NS, AS and JS APIs accept your Delete API calls again.

In a future version of The Things Stack we may consider extending the “restore window” to 7 days (up from 24 hours). We are also working on something that permanently deletes deleted applications (and their end devices) after the “restore window” expires. Hopefully that will be helpful if someone else in the future makes the same mistake.

2 Likes

Thank you so much! I agree extending the restore window would help because I finally found the restore command, but it was too late. Once again, thank you and have a nice day!

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.