{"record":{"id":"1009e895d11f9fd5","repo":"quickwit-oss/tantivy","slug":"invaliddata-1009e8","errorCode":"InvalidData","errorMessage":"No available applicable codec.","messagePattern":"No available applicable codec\\.","errorType":"error_code","errorClass":"io::Error","httpStatus":null,"severity":"error","filePath":"columnar/src/column_values/u64_based/mod.rs","lineNumber":177,"sourceCode":"        let val_u64 = val.to_u64();\n        stats_collector.collect(val_u64);\n        for (_, estimator) in &mut estimators {\n            estimator.collect(val_u64);\n        }\n    }\n    for (_, estimator) in &mut estimators {\n        estimator.finalize();\n    }\n    let stats = stats_collector.stats();\n    let (_, best_codec, best_codec_estimator) = estimators\n        .into_iter()\n        .flat_map(|(codec_type, estimator)| {\n            let num_bytes = estimator.estimate(&stats)?;\n            Some((num_bytes, codec_type, estimator))\n        })\n        .min_by_key(|(num_bytes, _, _)| *num_bytes)\n        .ok_or_else(|| {\n            io::Error::new(io::ErrorKind::InvalidData, \"No available applicable codec.\")\n        })?;\n    best_codec.to_code().serialize(wrt)?;\n    best_codec_estimator.serialize(\n        &stats,\n        &mut vals.boxed_iter().map(MonotonicallyMappableToU64::to_u64),\n        wrt,\n    )?;\n    Ok(())\n}\n\n/// Load u64-based column values.\n///\n/// This method first identifies the codec off the first byte.\npub fn load_u64_based_column_values<T: MonotonicallyMappableToU64>(\n    mut bytes: OwnedBytes,\n) -> io::Result<Arc<dyn ColumnValues<T>>> {\n    let codec_type: CodecType = bytes\n        .first()","sourceCodeStart":159,"sourceCodeEnd":195,"githubUrl":"https://github.com/quickwit-oss/tantivy/blob/b5d8deb80c26924e6b007a5b1a7630f35ca64de4/columnar/src/column_values/u64_based/mod.rs#L159-L195","documentation":"serialize_u64_based_column_values evaluates every registered codec's byte-size estimator against the column stats and picks the cheapest. If no codec's estimator returns Some (all returned None because none is applicable to the column's stats, e.g. cardinality/min-max ranges outside supported bounds), it raises InvalidData with 'No available applicable codec.' instead of writing a column with no codec.","triggerScenarios":"Calling serialize_u64_based_column_values / serialize_column_mappable_to_u64 / serialize_multivalued_index (directly or via a writer) on a column whose stats make every codec estimator decline: typically a column with zero values, empty value range, or stats none of the codecs accept. Also hit in tests test_fastfield_gcd / test_serialize_and_load_simple when estimator lists are empty.","commonSituations":"Indexing an all-empty or degenerate fast field; building a custom codec list where no estimator supports the value range (e.g. values exceeding u64/GCD-able bounds); a version change removing or gating a previously-default codec so nothing applies to legacy column shapes.","solutions":["Check the column's stats (num_vals, min/max) before serializing and skip or pad empty/degenerate columns","Ensure the default codec set is used (or include a fallback codec applicable to any stats) in the estimator list","Verify values fit the expected u64-mappable range before passing them to MonotonicallyMappableToU64-based serialization","Update to a version where an always-applicable fallback codec exists"],"exampleFix":"// before: serializing possibly-empty column\nserialize_u64_based_column_values(vals.boxed_iter(), &codecs, wrt)?;\n// after: guard empty columns\nif vals.iter().next().is_none() { /* write empty column or skip */ } else {\n    serialize_u64_based_column_values(vals.boxed_iter(), &codecs, wrt)?;\n}","handlingStrategy":"validation","validationCode":"fn can_serialize<T: MonotonicallyMappableToU64>(vals: &[T], codecs: &[(CodecType, CodecEstimator)]) -> bool {\n    let stats = PermutationStats::compute(&mut vals.iter().copied());\n    codecs.iter().any(|(_, est)| est.estimate(&stats).is_some())\n}\n// guard: if !can_serialize(&vals, &codecs) { skip/pad column }","typeGuard":null,"tryCatchPattern":"match serialize_u64_based_column_values(vals.boxed_iter(), &codecs, &mut w) {\n    Ok(()) => {},\n    Err(e) if e.kind() == io::ErrorKind::InvalidData && e.to_string().contains(\"No available applicable codec\") => skip_or_pad_column(),\n    Err(e) => return Err(e),\n}","preventionTips":["Skip or pad empty/degenerate columns before serializing","Include an always-applicable fallback codec in the codec list","Check column stats (num_vals, min/max) fit codec support ranges","Pin tantivy versions so codec availability is stable"],"tags":["io","serialization","codec","columnar"],"backgroundTag":"no-applicable-codec","analyzedSha":"b5d8deb80c26924e6b007a5b1a7630f35ca64de4","analyzedAt":"2026-09-05T13:20:51.521Z","contentChangedAt":"2026-09-05T13:20:51.521Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}