{"record":{"id":"d82887d27e422d43","repo":"quickwit-oss/tantivy","slug":"invertedindexplugin-is-a-built-in-use-invertedind","errorCode":null,"errorMessage":"InvertedIndexPlugin is a built-in; use InvertedIndexPluginWriter::new","messagePattern":"InvertedIndexPlugin is a built-in; use InvertedIndexPluginWriter::new","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/index/inverted_index_plugin.rs","lineNumber":69,"sourceCode":"        // reallocation in the hashmap. Check if this affects performance.\n        .map(|power| 1 << power)\n        .take_while(|capacity| compute_table_memory_size(*capacity) < table_memory_upper_bound)\n        .last()\n        .ok_or_else(|| {\n            crate::TantivyError::InvalidArgument(format!(\n                \"per thread memory budget (={per_thread_memory_budget}) is too small. Raise the \\\n                 memory budget or lower the number of threads.\"\n            ))\n        })\n}\n\nimpl SegmentPlugin for InvertedIndexPlugin {\n    fn extensions(&self) -> &[&str] {\n        &[\"fieldnorm\", \"term\", \"idx\", \"pos\"]\n    }\n\n    fn create_writer(&self, _ctx: &PluginWriterContext) -> crate::Result<Box<dyn PluginWriter>> {\n        unimplemented!(\"InvertedIndexPlugin is a built-in; use InvertedIndexPluginWriter::new\")\n    }\n\n    fn merge(&self, ctx: PluginMergeContext) -> crate::Result<()> {\n        // Field norms first: postings merge reads them back from the target segment.\n        merge_fieldnorms(&ctx)?;\n\n        debug_time!(\"write-postings\");\n        debug!(\"write-postings\");\n        let target_segment = ctx.target_segment;\n        let mut serializer = InvertedIndexSerializer::open(target_segment)?;\n        let fieldnorm_data = target_segment.open_read(SegmentComponent::FieldNorms)?;\n        let fieldnorm_readers = FieldNormReaders::open(fieldnorm_data)?;\n        write_postings_merge(\n            ctx.readers,\n            ctx.schema,\n            &mut serializer,\n            fieldnorm_readers,\n            ctx.doc_id_mapping,","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/quickwit-oss/tantivy/blob/b5d8deb80c26924e6b007a5b1a7630f35ca64de4/src/index/inverted_index_plugin.rs#L51-L87","documentation":"InvertedIndexPlugin's SegmentPlugin::create_writer is intentionally unimplemented because inverted index writing is built into tantivy's core segment writer. Users must construct an InvertedIndexPluginWriter via InvertedIndexPluginWriter::new instead of routing writes through the plugin trait. Hitting this means the generic plugin machinery incorrectly dispatched writer creation for the built-in plugin.","triggerScenarios":"Calling create_writer on an InvertedIndexPlugin instance, directly or via generic plugin-writer plumbing that resolves a plugin by its extensions (\"fieldnorm\", \"term\", \"idx\", \"pos\").","commonSituations":"Custom segment writer or tooling enumerating registered plugins and calling create_writer generically; incorrect plugin registration causing the built-in plugin to be treated as user-provided.","solutions":["Use InvertedIndexPluginWriter::new(...) to create the writer instead of the plugin trait method.","Exclude InvertedIndexPlugin from any generic plugin create_writer dispatch loop.","Register only non-built-in plugins in custom writer factories.","Upgrade tantivy if this arises from core code paths."],"exampleFix":"// before\nlet writer = inverted_index_plugin.create_writer(&ctx)?; // unimplemented!\n// after\nlet writer = InvertedIndexPluginWriter::new(ctx);","handlingStrategy":"type-guard","validationCode":"fn can_create_writer(plugin: &dyn SegmentPlugin) -> bool {\n    plugin.type_id() != std::any::TypeId::of::<InvertedIndexPlugin>()\n}","typeGuard":"fn is_builtin_inverted_index(plugin: &dyn SegmentPlugin) -> bool {\n    plugin.type_id() == std::any::TypeId::of::<InvertedIndexPlugin>()\n}","tryCatchPattern":null,"preventionTips":["Dispatch create_writer only to user-registered plugins; skip built-ins.","Use InvertedIndexPluginWriter::new for inverted index writing.","Centralize plugin factories so built-ins are never iterated generically."],"tags":["unimplemented","plugin","inverted-index","built-in"],"backgroundTag":"built-in-plugin-misuse","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"}