{"record":{"id":"1c24a3a6c2e8753c","repo":"dmtrKovalenko/fff","slug":"file-picker-not-initialized-call-fff-create-insta","errorCode":null,"errorMessage":"File picker not initialized. Call fff_create_instance first.","messagePattern":"File picker not initialized\\. Call fff_create_instance first\\.","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/fff-c/src/lib.rs","lineNumber":369,"sourceCode":"    let query_str = match unsafe { cstr_to_str(query) } {\n        Some(s) => s,\n        None => return FffResult::err(\"Query is null or invalid UTF-8\"),\n    };\n\n    let current_file_str = unsafe { optional_cstr(current_file) };\n    let page_size = default_u32(page_size, 100) as usize;\n    let min_combo_count = default_u32(min_combo_count, 3);\n    let combo_boost_multiplier = default_i32(combo_boost_multiplier, 100);\n\n    let picker_guard = match inst.picker.read() {\n        Ok(g) => g,\n        Err(e) => return FffResult::err(&format!(\"Failed to acquire file picker lock: {}\", e)),\n    };\n\n    let picker = match picker_guard.as_ref() {\n        Some(p) => p,\n        None => {\n            return FffResult::err(\"File picker not initialized. Call fff_create_instance first.\");\n        }\n    };\n\n    // Get query tracker ref for combo matching\n    let qt_guard = match inst.query_tracker.read() {\n        Ok(q) => q,\n        Err(_) => return FffResult::err(\"Failed to acquire query tracker lock\"),\n    };\n    let query_tracker_ref = qt_guard.as_ref();\n\n    let parser = QueryParser::default();\n    let parsed = parser.parse(query_str);\n\n    let results = picker.fuzzy_search(\n        &parsed,\n        query_tracker_ref,\n        FuzzySearchOptions {\n            max_threads: max_threads as usize,","sourceCodeStart":351,"sourceCodeEnd":387,"githubUrl":"https://github.com/dmtrKovalenko/fff/blob/7f8537e70f0ea1210f9acbbfc4640141105cdc78/crates/fff-c/src/lib.rs#L351-L387","documentation":"fff_search acquires the picker lock and then unwraps the Option<FilePicker>; if the slot is None the instance exists but its picker was never initialized (or was torn down). The library returns this error telling the caller to create an instance first.","triggerScenarios":"Calling fff_search with a valid FffInstance whose picker slot is None — e.g. an instance created through a path that skipped picker init, or after the picker was cleared/destroyed while the instance handle was still used.","commonSituations":"Using a stale instance handle after library shutdown or re-initialization; a previous fff_create_instance failure left a half-built instance; ordering bug where search is called before instance creation completes in async setup code.","solutions":["Call fff_create_instance (or _with) and confirm it returned a success result before searching.","If the instance was destroyed, obtain a fresh instance handle instead of reusing the old pointer.","Check initialization order in the host app: create instance → wait for success → search.","Enable logging around instance creation to confirm the picker actually initialized."],"exampleFix":"// before\nfff_search(inst, \"query\", ...); // inst may be uninitialized\n// after\nlet inst = fff_create_instance(c\"/project\");\nif inst.is_ok() { fff_search(inst, \"query\", ...); }","handlingStrategy":"type-guard","validationCode":"assert(inst ~= nil and inst ~= ffi.NULL, 'instance must be created before search')","typeGuard":"local function has_instance(h) return h ~= nil and h ~= ffi.NULL end","tryCatchPattern":"if not has_instance(inst) then\n  inst = fff.create_instance(vim.fn.getcwd())\nend\nlocal res = fff.search(inst, q)","preventionTips":["Check fff_create_instance's result before any search call.","Never reuse instance handles after fff_destroy_instance.","Serialize setup: init completes before UI search calls fire."],"tags":["ffi","initialization","lifecycle","null-pointer"],"backgroundTag":"resource-not-found","analyzedSha":"7f8537e70f0ea1210f9acbbfc4640141105cdc78","analyzedAt":"2026-09-10T07:26:53.407Z","contentChangedAt":"2026-09-10T07:26:53.407Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}