{"record":{"id":"d3ee0358e233f580","repo":"nikivdev/code","slug":"typesense-returned","errorCode":null,"errorMessage":"typesense returned {}","messagePattern":"typesense returned (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/install.rs","lineNumber":690,"sourceCode":"        .timeout(std::time::Duration::from_secs(5))\n        .build()?;\n    let url = format!(\n        \"{}/collections/{}/documents/search\",\n        config.url.trim_end_matches('/'),\n        config.collection\n    );\n    let payload = serde_json::json!({\n        \"q\": query,\n        \"query_by\": \"pkg_path,description\",\n        \"per_page\": 200,\n    });\n    let mut request = client.post(url).json(&payload);\n    if !config.api_key.is_empty() {\n        request = request.header(\"X-TYPESENSE-API-KEY\", &config.api_key);\n    }\n    let response = request.send().context(\"failed to query typesense\")?;\n    if !response.status().is_success() {\n        bail!(\"typesense returned {}\", response.status());\n    }\n    let body: TypesenseSearchResponse = response\n        .json()\n        .context(\"failed to parse typesense response\")?;\n    let mut entries = Vec::new();\n    for hit in body.hits {\n        entries.push(FloxDisplayEntry {\n            pkg_path: hit.document.pkg_path,\n            description: hit.document.description,\n            version: hit.document.version,\n            alias: None,\n        });\n    }\n    Ok(entries)\n}\n\nfn typesense_ensure_collection(config: &TypesenseConfig) -> Result<()> {\n    let client = Client::builder()","sourceCodeStart":672,"sourceCodeEnd":708,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/install.rs#L672-L708","documentation":"typesense_search performs an HTTP POST to the configured Typesense search endpoint. Any non-2xx response status aborts with 'typesense returned <status>'. The error surfaces the HTTP status so the developer can diagnose auth, collection, or query problems on the Typesense server side.","triggerScenarios":"The Typesense server responds with 4xx/5xx: bad/missing API key (401), unknown collection (404), malformed query payload (400), or server outage (5xx).","commonSituations":"Wrong or expired X-TYPESENSE-API-KEY; collection name mismatch in TypesenseConfig; Typesense host/port wrong or behind a proxy returning errors; index not yet built for the queried collection.","solutions":["Check the HTTP status in the message: 401/403 -> fix api_key; 404 -> run_index to create the collection; 5xx -> check Typesense server health","Verify TypesenseConfig (base URL, port 8108, collection, api_key)","Curl the Typesense endpoint directly with the same key and query to reproduce","Ensure the collection exists and is populated via run_index"],"exampleFix":"// before (no key configured -> 401)\nlet mut request = client.post(url).json(&payload);\n// after (key set, header applied)\nif !config.api_key.is_empty() {\n    request = request.header(\"X-TYPESENSE-API-KEY\", &config.api_key);\n}","handlingStrategy":"retry","validationCode":"// preflight: confirm Typesense is reachable and key valid\nlet health = reqwest::get(format!(\"{}/health\", base)).await?;\nif !health.status().is_success() {\n    bail!(\"typesense unreachable before search\");\n}","typeGuard":null,"tryCatchPattern":"match typesense_search(&config, query) {\n    Err(e) if e.to_string().starts_with(\"typesense returned\") => {\n        eprintln!(\"Typesense rejected the query ({}); falling back to flox CLI\", e);\n        // fall back to flox_search_with_aliases\n    }\n    other => other?,\n}","preventionTips":["Validate TypesenseConfig (URL, port, collection, api_key) at startup","Preflight /health before search","Fall back to the flox CLI search when Typesense errors","Monitor Typesense for 401/404 spikes to catch key/collection drift"],"tags":["http","typesense","api"],"backgroundTag":"upstream-http-error","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}