{"record":{"id":"394ea5dfbc568ccf","repo":"RyanCodrai/turbovec","slug":"e-394ea5","errorCode":null,"errorMessage":"{e}","messagePattern":"\\{e\\}","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"turbovec/src/lib.rs","lineNumber":1302,"sourceCode":"    /// As with [`Self::search`], none of the three can fire on an index\n    /// with no committed `dim` — that case returns the empty result\n    /// before any validation. Use [`Self::try_search_with_mask`] for the\n    /// non-panicking form.\n    pub fn search_with_mask(\n        &self,\n        queries: &[f32],\n        k: usize,\n        mask: Option<&[bool]>,\n    ) -> SearchResults {\n        // Single source of validation: the checked form below owns all\n        // three conditions, and this one turns them back into panics.\n        // Re-validating here instead would run `first_invalid_coord`'s\n        // O(nq·dim) scan twice per query batch. The payload is now the\n        // error's `Display` rather than an `assert_eq!` rendering, so\n        // three of the four sites report differently than they did —\n        // see `try_search_with_mask` for the before/after.\n        self.try_search_with_mask(queries, k, mask)\n            .unwrap_or_else(|e| panic!(\"{e}\"))\n    }\n\n    /// [`Self::search_with_mask`] as a `Result`: the non-panicking form.\n    ///\n    /// Returns [`SearchError::QueryBufferNotMultipleOfDim`],\n    /// [`SearchError::InvalidQueryValue`], or\n    /// [`SearchError::MaskLengthMismatch`]. On success the result is\n    /// exactly what `search_with_mask` would have returned.\n    ///\n    /// `search_with_mask` now calls this function and panics with the\n    /// error's `Display` text, so the two forms cannot diverge in what\n    /// they detect: the conditions, the order they are checked in and\n    /// the results returned are all exactly as before.\n    ///\n    /// The panic *text* did change at three of the four sites, which\n    /// were previously raised by `assert_eq!` and now carry the error's\n    /// `Display` alone. (Four sites, three conditions: the mask-length\n    /// check has one site for an empty index and one for a populated","sourceCodeStart":1284,"sourceCodeEnd":1320,"githubUrl":"https://github.com/RyanCodrai/turbovec/blob/ccab9f325e6ce2a270a87daf01ae4e443bcf2d49/turbovec/src/lib.rs#L1284-L1320","documentation":"search_with_mask is the panicking form of the masked search: it calls try_search_with_mask and panics with the error's Display on failure. Errors include QueryBufferNotMultipleOfDim (query buffer length not a multiple of dim) and InvalidQueryValue (NaN/inf/huge coordinates).","triggerScenarios":"Calling search_with_mask(queries, k, mask) with queries.len() % dim != 0, or with a NaN/inf/|v|>=1e16 coordinate in the query buffer; also reached via search().","commonSituations":"Concatenated query batches with a trailing partial vector; queries built from a different-dimension embedding model than the index; corrupted or unnormalized query embeddings.","solutions":["Switch to try_search_with_mask, the Result-returning non-panicking form, and match on SearchError.","Assert queries.len() % dim == 0 before the call and trim partial vectors.","Validate query coordinates are finite and |v| < 1e16 before searching."],"exampleFix":"// before\nlet hits = index.search_with_mask(&queries, 10, Some(&mask)); // panics\n// after\nassert_eq!(queries.len() % dim, 0, \"query buffer not multiple of dim\");\nlet hits = index.try_search_with_mask(&queries, 10, Some(&mask)).unwrap_or_default();","handlingStrategy":"validation","validationCode":"debug_assert_eq!(queries.len() % dim, 0, \"query buffer not multiple of dim\");\ndebug_assert!(queries.iter().all(|v| v.is_finite() && v.abs() < 1e16));","typeGuard":"fn queries_ok(q: &[f32], dim: usize) -> bool {\n    q.len() % dim == 0 && q.iter().all(|v| v.is_finite() && v.abs() < 1e16)\n}","tryCatchPattern":"// use the non-panicking form\nlet hits = index.try_search_with_mask(&queries, k, mask)\n    .unwrap_or_else(|e| { warn(\"{e}\"); Vec::new() });","preventionTips":["Keep query batches exact multiples of dim; pad or trim partials.","Use the same embedding model/dim for queries as for index build.","Prefer try_search_with_mask in libraries and services."],"tags":["rust","panic","vector-search","invalid-input"],"backgroundTag":"invalid-argument-value","analyzedSha":"ccab9f325e6ce2a270a87daf01ae4e443bcf2d49","analyzedAt":"2026-09-06T08:39:18.516Z","contentChangedAt":"2026-09-06T08:39:18.516Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}