When I implemented this function and tested it out, it output the wrong asset id endpoint. It was a decal asset id I copied from the creator page and I made sure the decal was public as well. It gave me the rbxassetid format when it should be the roblox.com one. Any ideas on why this is?
The way the code works is to assume that a failure to insert means that it was already an image and not a decal. However, technically there are some other rare backend failures which could happen. If you care about fixing the last 0.1% or whatever edge case you could attempt to parse the error message and determine what the error is (4xx error vs 5xx error), but the error messages aren’t guaranteed to stay the same so that would require more maintenance of the code.
TL;DR: You probably got very unlucky and there was a backend failure on that particular request.
Ah, yeah, it probably would have been good to put a check in the sample code that it’s being run on the server to avoid confusion because the pcall will mask the error if you do it on the client.
I’ve ran into an issue caused by the asset id being longer than it used. I stored the asset id with 6 characters (using 92 utf-8 char, because datastores only accept 93…), but that is insufficient now, and my stored assetids overflowed or got truncated (icons stopped displaying because of it). I do have quite an odd “game” so whatever, but is there a guarantee that the number wont go past a point?
I fixed it by instead using 10 characters rather than 6, so it can now store up to 19 digit numbers