We had made an assumption that searches with nid=XXXXXXX values should be cleaned up to URLs with /gnd/XXXXXXX, and are for non-release entities, while searches with idn=XXXXXXX should be cleaned up to /XXXXXXX (no /gnd) and are for only releases. This turns out to be completely wrong: a link such as https://portal.dnb.de/opac/opacPresentation?cqlMode=true&reset=true&referrerPosition=0&referrerResultId=coriolan%26any&query=idn%3D30001502X is perfectly valid, and not for a release (for a work, in this case, which we still do not support but for which we're adding support with
This gives us two options:
a) always clean up to /XXXXXXX (drop /gnd) - gives us only one possible version of every link and they always (seemingly) work, but the permalink for non-release stuff does include /gnd (or /dnbn for labels), so we wouldn't be storing the real permalinks
b) clean up as we have been doing now (/gnd for nid, no /gnd for idn) and just allow both versions for non-release entities. This allows us to still have permalinks, but risks duplicates.
After a conversation on IRC with yvanzo we decided to go with b) for now, and maybe contact DNB and ask them why this works like this and improve it further later.