Back to n8n workflow hardening
code/build_dead_letter.js
// SYNTHETIC. Run Once for All Items. Linked input identity must survive HTTP errors.
return $input.all().map((item,index) => {
const original = $('Prepare Events').itemMatching(index).json;
if (!original?.idempotencyKey || !original.payload) throw new Error('DLQ_ORIGIN_MISSING');
return {json:{synthetic:true,dead_letter_key:'dlq:' + original.idempotencyKey,
idempotencyKey:original.idempotencyKey,payload:original.payload,
status:'awaiting_review',reason:'DELIVERY_RETRIES_EXHAUSTED',
execution_id:String($execution.id || 'synthetic-local')},pairedItem:{item:index}};
});