quickwit-oss/quickwit · error

attempt to serialize Option::None value

Error message

attempt to serialize Option::None value

What it means

The `to_simple_list` serde helper, which serializes an `Option<Vec<T>>` into a comma-separated query-string value, unwrapped `None` via `.expect`. The helper is only intended to be registered with `serialize_with` on fields that are always `Some` at serialization time (typically defaulted), so hitting `None` means the field was never populated — an internal invariant violation in the handler, not user input.

Source

Thrown at quickwit/quickwit-serve/src/simple_list.rs:32

use std::str::FromStr;

use serde::{Deserialize, Deserializer, Serializer};

/// Serializes an `Option<&[Serialize]>` with
/// `Some(value)` to a comma separated string of values.
/// Used to serialize values within the query string
pub fn to_simple_list<S, T>(
    value: &Option<Vec<T>>,
    serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where
    S: Serializer,
    T: ToString,
{
    let vec = &value
        .as_ref()
        .expect("attempt to serialize Option::None value");

    let serialized_str = vec
        .iter()
        .map(|value| value.to_string())
        .collect::<Vec<_>>() // do not collect here
        .join(",");

    serializer.serialize_str(&serialized_str)
}

/// Deserializes a comma separated string of values
/// into a [`Vec<T>`].
/// Used to deserialize list of values from the query string.
pub fn from_simple_list<'de, D, T>(deserializer: D) -> Result<Option<Vec<T>>, D::Error>
where
    D: Deserializer<'de>,
    T: FromStr,
    <T as FromStr>::Err: ToString,

View on GitHub (pinned to a39730c5cd)

Solutions

  1. Ensure the field using `to_simple_list` is populated (defaults applied) before the response is serialized
  2. Use `skip_serializing_if` or a helper that handles `None` if the field is genuinely optional
  3. Report as a bug if the endpoint response should always contain the field
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at quickwit/quickwit-serve/src/simple_list.rs:32 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of quickwit-oss/quickwit@a39730c5cd (2026-09-08). Data as JSON: /api/errors/767d7d06ba9ebdf8. Report an issue: GitHub.