{"record":{"id":"d4cf99f8e4da8920","repo":"nikivdev/code","slug":"typesense-import-failed","errorCode":null,"errorMessage":"typesense import failed ({})","messagePattern":"typesense import failed \\((.+?)\\)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/install.rs","lineNumber":777,"sourceCode":"    );\n    let mut body = String::new();\n    for entry in entries {\n        let doc = serde_json::json!({\n            \"id\": entry.pkg_path,\n            \"pkg_path\": entry.pkg_path,\n            \"description\": entry.description,\n            \"version\": entry.version\n        });\n        body.push_str(&doc.to_string());\n        body.push('\\n');\n    }\n    let mut request = client.post(&url).body(body);\n    if !config.api_key.is_empty() {\n        request = request.header(\"X-TYPESENSE-API-KEY\", &config.api_key);\n    }\n    let resp = request.send().context(\"failed to import into typesense\")?;\n    if !resp.status().is_success() {\n        bail!(\"typesense import failed ({})\", resp.status());\n    }\n    Ok(())\n}\n\nfn load_index_queries(query: Option<String>, path: Option<PathBuf>) -> Result<Vec<String>> {\n    let mut out = Vec::new();\n    if let Some(path) = path {\n        let content = fs::read_to_string(&path)\n            .with_context(|| format!(\"failed to read {}\", path.display()))?;\n        for line in content.lines() {\n            let trimmed = line.trim();\n            if trimmed.is_empty() || trimmed.starts_with('#') {\n                continue;\n            }\n            out.push(trimmed.to_string());\n        }\n    }\n    if let Some(query) = query {","sourceCodeStart":759,"sourceCodeEnd":795,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/install.rs#L759-L795","documentation":"typesense_import bulk-imports documents into the Typesense collection via POST. A non-success response bails with 'typesense import failed (<status>)'. Note Typesense can return 200 with per-document import errors in the body — those are not caught here.","triggerScenarios":"The import POST returns 4xx/5xx during run_index: bad API key (401), missing collection (404 — ensure_collection not run or failed), payload too large (413), or server errors.","commonSituations":"Running import before the collection exists; importing very large batches hitting request size limits; read-only API key; Typesense disk-full (503).","solutions":["Ensure typesense_ensure_collection succeeded before importing","Check the status: 404 -> create collection; 401/403 -> fix api_key; 413 -> chunk the import into smaller batches","Inspect Typesense server logs/disk space for 5xx responses","Also check the response body even on 200 — Typesense reports per-doc import errors there"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// ensure collection exists before importing\nlet head = client.get(format!(\"{}/collections/{}\", base, collection))\n    .header(\"X-TYPESENSE-API-KEY\", &api_key)\n    .send().await?;\nif head.status().as_u16() == 404 {\n    bail!(\"run ensure_collection before import\");\n}","typeGuard":null,"tryCatchPattern":"match run_index() {\n    Err(e) if e.to_string().contains(\"typesense import failed\") => {\n        eprintln!(\"Import rejected ({}); retry with smaller batch after checking collection/key\", e);\n    }\n    other => other?,\n}","preventionTips":["Always run ensure_collection before import","Chunk imports into batches well under Typesense request limits","Use a write-capable API key for imports","Check import response bodies even on 200 for per-document errors"],"tags":["http","typesense","bulk-import"],"backgroundTag":"upstream-http-error","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}