{"record":{"id":"226224cf9db90a60","repo":"vectordotdev/vector","slug":"finalizer-must-exist-for-the-batch-receiver-to-be-created","errorCode":null,"errorMessage":"Finalizer must exist for the batch receiver to be created","messagePattern":"Finalizer must exist for the batch receiver to be created","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/sources/aws_sqs/source.rs","lineNumber":165,"sourceCode":"                        \"aws_sqs\",\n                        body.as_bytes(),\n                        timestamp,\n                        &batch,\n                        self.log_namespace,\n                        &events_received,\n                    );\n                    events.extend(decoded);\n                }\n            }\n            drop(batch); // Drop last reference to batch acknowledgement finalizer\n            let count = events.len();\n\n            match out.send_batch(events).await {\n                Ok(()) => {\n                    if self.delete_message {\n                        match batch_receiver {\n                            Some(receiver) => finalizer\n                                .expect(\"Finalizer must exist for the batch receiver to be created\")\n                                .add(receipts_to_ack, receiver),\n                            None => {\n                                delete_messages(\n                                    self.client.clone(),\n                                    receipts_to_ack,\n                                    self.queue_url.clone(),\n                                )\n                                .await\n                            }\n                        }\n                    }\n                }\n                Err(_) => emit!(StreamClosedError { count }),\n            }\n        }\n    }\n}\n","sourceCodeStart":147,"sourceCodeEnd":183,"githubUrl":"https://github.com/vectordotdev/vector/blob/bdb87aeaa4c4ff27c0ba643c1c77b21bf2ef4013/src/sources/aws_sqs/source.rs#L147-L183","documentation":"Invariant expectation in the aws_sqs source run loop: events are decoded with a batch receiver whose acknowledgement finalizer is created earlier in the same iteration. This fires only if that finalizer were absent when the receiver is constructed — impossible in the current control flow — so the string documents why the unwrap is safe: the batch ack finalizer is always created before the decoder that needs it.","triggerScenarios":"Thrown at src/sources/aws_sqs/source.rs:165 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["If observed, it indicates the batch/finalizer construction order was refactored incorrectly — restore creation of the finalizer before the receiver","Add a unit test asserting the receiver is only built after the finalizer exists"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"bdb87aeaa4c4ff27c0ba643c1c77b21bf2ef4013","analyzedAt":"2026-09-16T02:53:35.741Z","contentChangedAt":"2026-09-16T02:53:35.741Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}