{"record":{"id":"146e729518f9396f","repo":"dmtrKovalenko/fff","slug":"failed-to-serialize-health-check","errorCode":null,"errorMessage":"Failed to serialize health check: {}","messagePattern":"Failed to serialize health check: (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"info","filePath":"crates/fff-c/src/lib.rs","lineNumber":1338,"sourceCode":"                        serde_json::Value::Object(db_health),\n                    );\n                }\n            }\n            Err(_) => {\n                query_info.insert(\"initialized\".to_string(), serde_json::Value::Bool(false));\n            }\n        }\n    } else {\n        query_info.insert(\"initialized\".to_string(), serde_json::Value::Bool(false));\n    }\n    health.insert(\n        \"query_tracker\".to_string(),\n        serde_json::Value::Object(query_info),\n    );\n\n    match serde_json::to_string(&health) {\n        Ok(json) => FffResult::ok_string(&json),\n        Err(e) => FffResult::err(&format!(\"Failed to serialize health check: {}\", e)),\n    }\n}\n\n/// Free a search result returned by `fff_search`: the struct, its `items`\n/// and `scores` arrays, and every string within.\n///\n/// ## Safety\n/// `result` must be a valid pointer previously returned via `FffResult.handle`\n/// from `fff_search`, or null (no-op).\n#[unsafe(no_mangle)]\npub unsafe extern \"C\" fn fff_free_search_result(result: *mut FffSearchResult) {\n    if result.is_null() {\n        return;\n    }\n\n    unsafe {\n        let result = Box::from_raw(result);\n        let count = result.count as usize;","sourceCodeStart":1320,"sourceCodeEnd":1356,"githubUrl":"https://github.com/dmtrKovalenko/fff/blob/7f8537e70f0ea1210f9acbbfc4640141105cdc78/crates/fff-c/src/lib.rs#L1320-L1356","documentation":"fff_health_check builds a health JSON object and serializes it with serde_json::to_string; if serialization fails, this error is returned. This is rare because the input is a constructed serde_json::Value, but it guards the FFI boundary against any serialization failure.","triggerScenarios":"Calling fff_health_check when serde_json cannot serialize the assembled health map — practically only due to a serde_json internal failure such as an exhausted allocator or a non-string map key that slipped into the construction.","commonSituations":"Extremely low-memory environments; custom/patched serde_json builds with strict settings; latent library bug putting invalid data into the health object.","solutions":["Retry the call — transient allocation failures may resolve.","Check process memory availability if running in constrained environments.","Verify you are using a compatible serde_json version if linking statically.","Report to maintainers if reproducible — serializing a built Value should not fail."],"exampleFix":"null","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"local res = fff.health_check(inst)\nif res.is_err then health_json = '{}' end","preventionTips":["Ensure adequate process memory in constrained environments.","Retry once on transient serialization failures.","Report reproducible failures upstream — this should never fire."],"tags":["ffi","serde","json","serialization"],"backgroundTag":"json-serialization-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"}