{"record":{"id":"d1b86412571c0298","repo":"tinyhumansai/openhuman","slug":"memory-chunk-context-target-chunk-not-found-in-so","errorCode":null,"errorMessage":"memory_chunk_context: target chunk not found in source (source may have >500 chunks)","messagePattern":"memory_chunk_context: target chunk not found in source \\(source may have >500 chunks\\)","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src/openhuman/memory/tools/search/chunk_context.rs","lineNumber":128,"sourceCode":"        let source_query = ChunkQuery {\n            source_kind: Some(source_kind),\n            source_id: Some(source_id.clone()),\n            limit: Some(500),\n            ..Default::default()\n        };\n        let mut source_chunks = chunk_reader\n            .list_chunks(&source_query, None)\n            .await\n            .map_err(|e| anyhow::anyhow!(\"memory_chunk_context: source query failed: {e}\"))?;\n\n        // Sort by seq_in_source (ascending) for natural reading order\n        source_chunks.sort_by_key(|c| c.seq_in_source);\n\n        // Find the target's position\n        let target_pos = source_chunks\n            .iter()\n            .position(|c| c.id == parsed.chunk_id)\n            .ok_or_else(|| anyhow::anyhow!(\n                \"memory_chunk_context: target chunk not found in source (source may have >500 chunks)\"\n            ))?;\n\n        // Compute window bounds\n        let start = target_pos.saturating_sub(window);\n        let end = (target_pos + window + 1).min(source_chunks.len());\n        let window_chunks = &source_chunks[start..end];\n\n        let mut output = format!(\n            \"Source: {}:{} ({} total chunks)\\n\\\n             Showing chunks {}-{} (target at position {}):\\n\\n\",\n            source_kind.as_str(),\n            source_id,\n            source_chunks.len(),\n            start,\n            end - 1,\n            target_pos,\n        );","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/tinyhumansai/openhuman/blob/749120085864ce16e0f273c7b86fac7740b39c5b/src/openhuman/memory/tools/search/chunk_context.rs#L110-L146","documentation":"The source listing succeeded (capped at 500 chunks) but the target chunk's seq_in_source was not found among the returned rows — the source has more than 500 chunks and the target falls outside the fetched window. A documented limitation of the neighbour-window algorithm.","triggerScenarios":"Thrown at src/openhuman/memory/tools/search/chunk_context.rs:128 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Narrow the context request to a more recent chunk within the first 500 of the source","Use a time-scoped search (cover_window) to re-locate the chunk","Report the source as too large for chunk_context"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"749120085864ce16e0f273c7b86fac7740b39c5b","analyzedAt":"2026-08-17T21:21:45.363Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}