// main.js
var nodeLib = require('/lib/xp/node');
var event = require('/lib/xp/event');
event.listener({
type: 'node.rename',
callback: function(event) {
var repo = nodeLib.connect({
repoId: 'cms-repo',
branch: 'draft'
});
var eventNode = event.data.nodes.pop();
var node = repo.get(eventNode.id);
if (!node) log.info('Missing node') // <-- This kicks in every time
else {
/* do things with node */
}
}
});
The callback for the event listener is called in a different context. It might be that when calling repo.get() you don’t have permissions to read the node.
Try passing the user in the call to nodelib.connect(...).