{"record":{"id":"e0a2178e45c265a2","repo":"dmtrKovalenko/fff","slug":"failed-to-get-historical-query","errorCode":null,"errorMessage":"Failed to get historical query: {}","messagePattern":"Failed to get historical query: (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"crates/fff-c/src/lib.rs","lineNumber":1150,"sourceCode":"            Some(p) => p.base_path().to_path_buf(),\n            None => return FffResult::ok_empty(),\n        }\n    };\n\n    let qt_guard = match inst.query_tracker.read() {\n        Ok(q) => q,\n        Err(_) => return FffResult::ok_empty(),\n    };\n\n    let tracker = match qt_guard.as_ref() {\n        Some(t) => t,\n        None => return FffResult::ok_empty(),\n    };\n\n    match tracker.get_historical_query(&project_path, offset as usize) {\n        Ok(Some(query)) => FffResult::ok_string(&query),\n        Ok(None) => FffResult::ok_empty(),\n        Err(e) => FffResult::err(&format!(\"Failed to get historical query: {}\", e)),\n    }\n}\n\n/// Get health check information.\n///\n/// ## Safety\n/// * `fff_handle` must be a valid instance pointer from `fff_create_instance`, or null for\n///   a limited health check (version + git only).\n/// * `test_path` can be null or a valid null-terminated UTF-8 string.\n#[unsafe(no_mangle)]\npub unsafe extern \"C\" fn fff_health_check(\n    fff_handle: *mut c_void,\n    test_path: *const c_char,\n) -> *mut FffResult {\n    let test_path = unsafe { optional_cstr(test_path) }\n        .map(PathBuf::from)\n        .unwrap_or_else(|| std::env::current_dir().unwrap_or_default());\n","sourceCodeStart":1132,"sourceCodeEnd":1168,"githubUrl":"https://github.com/dmtrKovalenko/fff/blob/7f8537e70f0ea1210f9acbbfc4640141105cdc78/crates/fff-c/src/lib.rs#L1132-L1168","documentation":"fff_get_historical_query fetches a past query from the query tracker; if tracker.get_historical_query returns Err (a database read failure), this error message is returned. Note Ok(None) is not an error — it returns an empty result — so this fires only on actual DB errors.","triggerScenarios":"Calling fff_get_historical_query when the underlying query-history database read fails: corrupted LMDB file, I/O error, permission denied on the DB, or lock contention with a concurrent writer.","commonSituations":"Query history database deleted or corrupted between sessions; DB directory permissions changed; reading history while another process holds the LMDB write lock; disk I/O errors.","solutions":["Check the inner error payload for the database failure reason.","Verify the query history DB files exist and are readable by the process.","Recreate the query history database if it is corrupted (history is expendable).","Retry after a short delay if a concurrent writer held the lock.","Fall back to empty history in the UI instead of surfacing an error."],"exampleFix":"null","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"local res = fff.get_historical_query(inst, project, 0)\nif res.is_err or res.is_empty then history = {} end -- degrade gracefully","preventionTips":["Guard the DB files against deletion/corruption between sessions.","Verify DB directory permissions after deployment changes.","Show empty history instead of an error when the DB read fails."],"tags":["ffi","database","lmdb","read-failed"],"backgroundTag":"database-query-failed","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"}