reacherhq/check-if-email-exists · warning
No messages in the event
Error message
No messages in the event
What it means
The Lambda SQS handler is designed to receive exactly one message per event and takes the first record with expect(). If the SQS event arrives with zero records, the panic "No messages in the event" aborts the Lambda invocation. It guards an assumption about the event shape that batch sizes or test invocations can violate.
Solutions
- Return an error instead of panicking when records are empty, letting the Lambda runtime report it cleanly.
- Ensure test invocations use a proper SQS event sample containing one Records entry.
- Verify the function's event source mapping is attached to the intended SQS queue.
- Handle the single-message assumption explicitly with records.first().ok_or(...).
Example fix
// before
let message = request.records.first().expect("No messages in the event");
// after
let message = request.records.first().ok_or_else(|| anyhow::anyhow!("No messages in the event"))?; Defensive patterns
Strategy: try-catch
Validate before calling
if event.records.is_empty() {
return Err(anyhow::anyhow!("SQS event contained no records"));
} Type guard
fn has_records(event: &SQSPayload) -> bool {
!event.records.is_empty()
} Try / catch
// in the handler, replace expect with graceful error return
let message = request.records.first().ok_or_else(|| {
error!("SQS event had zero records");
anyhow::anyhow!("No messages in the event")
})?; Prevention
- Use realistic SQS event samples (with a non-empty Records array) when testing in the Lambda console.
- Verify the SQS event source mapping targets the correct queue.
- Prefer ok_or(...)? over expect()/unwrap() in Lambda handlers so panics do not hit the runtime.
When it happens
Trigger: An SQS event with an empty Records array is delivered — e.g. a direct Lambda test invocation with an empty event body, or an SQS/Lambda integration delivering a zero-record event (possible with certain batch configurations or malformed test payloads).
Common situations: Developers testing the Lambda from the AWS console with `{}` or an empty sample event; pipeline integrations (EventBridge pipes, S3→SQS setups) invoking with unexpected payloads; races where a batch is drained before delivery.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- Invalid host
- Invalid port
- Environment variable RCH_MINIMUM_TASK_CONCURRENCY should…
- Environment variable RCH_MAXIMUM_CONCURRENT_TASK_FETCH…
AI-assisted analysis of reacherhq/check-if-email-exists@81da93e8a4 (2026-09-11).
Data as JSON: /api/errors/5096a20861e21ac7.
Report an issue: GitHub.
Appendix: source
Thrown at sqs/src/main.rs:94
// show up in a confusing manner in CloudWatch logs.
.with_ansi(false)
// disabling time is handy because CloudWatch will add the ingestion time.
.without_time()
// remove the name of the function from every log entry
.with_target(false)
.init();
info!(version=?CARGO_PKG_VERSION, "Starting Reacher SQS lambda.");
run_and_wait_chromedriver().await?;
lambda_runtime::run(service_fn(handler)).await?;
Ok(())
}
async fn handler(event: LambdaEvent<SQSPayload>) -> Result<CheckEmailOutput, Error> {
let (request, _context) = event.into_parts();
// Since we're only fetching a single message, we can safely unwrap here.
let message = request.records.first().expect("No messages in the event");
let task: CheckEmailPartialTask = serde_json::from_str(&message.body)?;
info!(email = ?task.input.to_email, "Processing task");
let backend_config = Arc::new(load_config().await?);
debug!("{:#?}", backend_config);
let task = &task.into_check_email_task(backend_config.clone());
let worker_output = check_email_and_send_result(task).await;
match worker_output.as_ref() {
Ok(output) => {
info!(email = ?output.input, is_reachable = ?output.is_reachable, "Task completed");
}
Err(e) => {
info!(email = ?task.input.to_email, err = ?e, "Task failed");
}
}
View on GitHub (pinned to 81da93e8a4)