vectordotdev/vector · error

Serializer does not support JSON

Error message

Serializer does not support JSON

What it means

Panic from `.expect("all required builder params specified")` on `DeleteMessageBatchRequestEntry::builder().build()` in the `Ok` (skip-success) arm of `run_once`. Like the other builder expects, aws-sdk-sqs `build()` returns Err only when required setters (`id`, `receipt_handle`) were omitted; here both are set, so a failure signals a broken invariant or SDK API change rather than bad input data.

Solutions

  1. Confirm `.id(message_id)` and `.receipt_handle(receipt_handle)` are both chained immediately before `.build()`.
  2. Check for ownership issues: `receipt_handle` is moved here; ensure no earlier code in the same arm moved it first (compiler will normally catch this).
  3. Pin/align the aws-sdk-sqs version with vector's expected one and re-check builder required fields.
  4. Swap the expect for graceful error handling so a bad entry skips deletion instead of crashing the source.

Example fix

// before
DeleteMessageBatchRequestEntry::builder()
    .id(message_id)
    .receipt_handle(receipt_handle)
    .build()
    .expect("all required builder params specified")
// after
let entry = DeleteMessageBatchRequestEntry::builder()
    .id(message_id)
    .receipt_handle(receipt_handle)
    .build()
    .unwrap_or_else(|e| panic!("SQS delete entry invalid: {e}"));
Defensive patterns

Strategy: validation

Validate before calling

fn build_delete_entry(id: String, receipt_handle: String) -> Option<DeleteMessageBatchRequestEntry> {
    if id.is_empty() || receipt_handle.is_empty() { return None; }
    DeleteMessageBatchRequestEntry::builder().id(id).receipt_handle(receipt_handle).build().ok()
}

Type guard

fn has_receipt(m: &SqsMessage) -> bool { m.receipt_handle.as_deref().map_or(false, |r| !r.is_empty()) }

Try / catch

if let Ok(entry) = DeleteMessageBatchRequestEntry::builder().id(id).receipt_handle(rh).build() {
    delete_entries.push(entry);
} else { warn!("skipping invalid delete entry"); }

Prevention

When it happens

Trigger: Building a delete entry without `.id()` or `.receipt_handle()` at src/sources/aws_s3/sqs.rs:524 — typically after a refactor moves the `receipt_handle` variable (it is consumed here without clone) or an aws-sdk upgrade changes required builder fields.

Common situations: aws-sdk-sqs crate upgrade; moving `receipt_handle` into an earlier branch so the value is no longer available; copying this block elsewhere and forgetting one setter.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of vectordotdev/vector@bdb87aeaa4 (2026-09-16). Data as JSON: /api/errors/3ee0ba2368e2f7b8. Report an issue: GitHub.

Appendix: source

Thrown at lib/codecs/src/encoding/serializer.rs:473

    ///
    /// # Panics
    ///
    /// Panics if the serializer does not support encoding to JSON. Call `Serializer::supports_json`
    /// if you need to determine the capability to encode to JSON at runtime.
    pub fn to_json_value(&self, event: Event) -> Result<serde_json::Value, vector_common::Error> {
        match self {
            Serializer::Gelf(serializer) => serializer.to_json_value(event),
            Serializer::Json(serializer) => serializer.to_json_value(event),
            Serializer::NativeJson(serializer) => serializer.to_json_value(event),
            Serializer::Avro(_)
            | Serializer::Cef(_)
            | Serializer::Csv(_)
            | Serializer::Logfmt(_)
            | Serializer::Text(_)
            | Serializer::Native(_)
            | Serializer::Protobuf(_)
            | Serializer::RawMessage(_) => {
                panic!("Serializer does not support JSON")
            }
            #[cfg(feature = "syslog")]
            Serializer::Syslog(_) => {
                panic!("Serializer does not support JSON")
            }
            #[cfg(feature = "opentelemetry")]
            Serializer::Otlp(_) => {
                panic!("Serializer does not support JSON")
            }
        }
    }

    /// Returns the chunking implementation for the serializer, if any is supported.
    pub fn chunker(&self) -> Option<Chunker> {
        match self {
            Serializer::Gelf(gelf) => Some(Chunker::Gelf(gelf.chunker())),
            _ => None,
        }

View on GitHub (pinned to bdb87aeaa4)