{"record":{"id":"767d7d06ba9ebdf8","repo":"quickwit-oss/quickwit","slug":"attempt-to-serialize-option-none-value","errorCode":null,"errorMessage":"attempt to serialize Option::None value","messagePattern":"attempt to serialize Option::None value","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"quickwit/quickwit-serve/src/simple_list.rs","lineNumber":32,"sourceCode":"\nuse std::str::FromStr;\n\nuse serde::{Deserialize, Deserializer, Serializer};\n\n/// Serializes an `Option<&[Serialize]>` with\n/// `Some(value)` to a comma separated string of values.\n/// Used to serialize values within the query string\npub fn to_simple_list<S, T>(\n    value: &Option<Vec<T>>,\n    serializer: S,\n) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>\nwhere\n    S: Serializer,\n    T: ToString,\n{\n    let vec = &value\n        .as_ref()\n        .expect(\"attempt to serialize Option::None value\");\n\n    let serialized_str = vec\n        .iter()\n        .map(|value| value.to_string())\n        .collect::<Vec<_>>() // do not collect here\n        .join(\",\");\n\n    serializer.serialize_str(&serialized_str)\n}\n\n/// Deserializes a comma separated string of values\n/// into a [`Vec<T>`].\n/// Used to deserialize list of values from the query string.\npub fn from_simple_list<'de, D, T>(deserializer: D) -> Result<Option<Vec<T>>, D::Error>\nwhere\n    D: Deserializer<'de>,\n    T: FromStr,\n    <T as FromStr>::Err: ToString,","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/quickwit-oss/quickwit/blob/a39730c5cdcd1a4fe798403737ae293999ea21f8/quickwit/quickwit-serve/src/simple_list.rs#L14-L50","documentation":"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.","triggerScenarios":"Thrown at quickwit/quickwit-serve/src/simple_list.rs:32 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the field using `to_simple_list` is populated (defaults applied) before the response is serialized","Use `skip_serializing_if` or a helper that handles `None` if the field is genuinely optional","Report as a bug if the endpoint response should always contain the field"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a39730c5cdcd1a4fe798403737ae293999ea21f8","analyzedAt":"2026-09-08T13:19:37.784Z","contentChangedAt":"2026-09-08T13:19:37.784Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}