{"record":{"id":"af2b73f1c4efc429","repo":"quickwit-oss/tantivy","slug":"the-json-field-does-not-support-custom-field-types","errorCode":null,"errorMessage":"the JSON field does not support custom field types","messagePattern":"the JSON field does not support custom field types","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/core/json_utils.rs","lineNumber":231,"sourceCode":"                term_buffer.append_type_and_fast_value(val);\n                postings_writer.subscribe(doc, 0u32, term_buffer, ctx);\n            }\n            ReferenceValueLeaf::PreTokStr(_) => {\n                unimplemented!(\n                    \"Pre-tokenized string support in dynamic fields is not yet implemented\"\n                )\n            }\n            ReferenceValueLeaf::Bytes(_) => {\n                unimplemented!(\"Bytes support in dynamic fields is not yet implemented\")\n            }\n            ReferenceValueLeaf::Facet(_) => {\n                unimplemented!(\"Facet support in dynamic fields is not yet implemented\")\n            }\n            ReferenceValueLeaf::IpAddr(_) => {\n                unimplemented!(\"IP address support in dynamic fields is not yet implemented\")\n            }\n            ReferenceValueLeaf::Custom(_) => {\n                unimplemented!(\"the JSON field does not support custom field types\")\n            }\n        },\n        ReferenceValue::Array(elements) => {\n            for val in elements {\n                index_json_value(\n                    doc,\n                    val,\n                    text_analyzer,\n                    term_buffer,\n                    json_path_writer,\n                    postings_writer,\n                    ctx,\n                    positions_per_path,\n                );\n            }\n        }\n        ReferenceValue::Object(object) => {\n            index_json_object::<V>(","sourceCodeStart":213,"sourceCodeEnd":249,"githubUrl":"https://github.com/quickwit-oss/tantivy/blob/b5d8deb80c26924e6b007a5b1a7630f35ca64de4/src/core/json_utils.rs#L213-L249","documentation":"index_json_value panics via unimplemented!() when the JSON leaf is a Custom value type. Dynamic JSON fields do not support custom field types by design; custom types require dedicated schema plumbing. The panic is an explicit not-implemented marker.","triggerScenarios":"Indexing a document where a JSON field's leaf value is a Custom(...) ReferenceValue via index_document.","commonSituations":"Custom integrations or plugins pushing bespoke value types through the generic JSON indexing path; test fixtures reusing typed-field values inside JSON objects.","solutions":["Ensure values routed to JSON fields are plain JSON scalars/arrays/objects","Handle custom types in a dedicated typed field rather than dynamic JSON indexing","Convert the custom value into a supported representation before indexing"],"exampleFix":"// before\njson_obj.insert(\"x\", custom_value);\n// after\njson_obj.insert(\"x\", Value::Str(custom_value.to_string()));","handlingStrategy":"validation","validationCode":"fn ensure_plain_json(v: &serde_json::Value) -> Result<(), &'static str> {\n    match v {\n        serde_json::Value::Null | serde_json::Value::Bool(_) | serde_json::Value::Number(_)\n        | serde_json::Value::String(_) => Ok(()),\n        serde_json::Value::Array(a) => a.iter().try_for_each(ensure_plain_json),\n        serde_json::Value::Object(o) => o.values().try_for_each(ensure_plain_json),\n    }\n}","typeGuard":"fn is_custom_leaf(v: &tantivy::schema::Value) -> bool {\n    matches!(v.as_value(), tantivy::schema::ReferenceValueLeaf::Custom(_))\n}","tryCatchPattern":"let result = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| index_writer.add_document(doc)));\nif result.is_err() { eprintln!(\"JSON field contained a custom value type\"); }","preventionTips":["Only feed plain JSON values into dynamic JSON fields","Handle custom types with dedicated typed fields and custom indexing logic","Sanitize payloads at ingestion boundaries","Review plugin/integration code that injects custom ReferenceValues"],"tags":["rust","unimplemented","json","custom-types","dynamic-fields"],"backgroundTag":"unimplemented-dynamic-field-type","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"}