When the source document already contains an Id attribute, but it is prefixed with a namespace, eg foo:Id, the ensureHasId function will detect this Id and move on because it only looks for the Id part in the localName. However in the addAllReferences funciton, the logic is to look for the Id attributes without prefixes only.
for (const attr of this.idAttributes) {
id = node.getAttribute(attr);
if (id) {
break;
}
}
Therefore preexisting prefixed Id attributes are not detected and the error No ID attribute found on node for reference: ${ref.xpath} is thrown.
Aditionally, since Objects and KeyInfo are added after ensureHasId is ran, if they do not have Id attributes already defined in their configuration, they will not be automatically added.
The solution for both problems is to run ensureHasId() once again in the addAllReferences() function instead of trying to re-detect the Id attribute.