openai/codex · error · MemoriesBackendError
queries must not be empty or contain empty strings
Error message
queries must not be empty or contain empty strings
What it means
Thrown by the memories search path (codex-rs/ext/memories/src/local/search.rs:21-28) before any scanning happens. Every string in SearchMemoriesRequest.queries is trimmed, then the request is rejected if the resulting list is empty or if any single query is empty after trimming. Empty needles would match every line, so the backend treats them as a caller bug.
Source
Thrown at codex-rs/ext/memories/src/backend.rs:157
#[error("ad-hoc note must not be empty")]
EmptyAdHocNote,
#[error("ad-hoc note '{filename}' already exists")]
AdHocNoteAlreadyExists { filename: String },
#[error("path '{path}' {reason}")]
InvalidPath { path: String, reason: String },
#[error("cursor '{cursor}' {reason}")]
InvalidCursor { cursor: String, reason: String },
#[error("path '{path}' was not found")]
NotFound { path: String },
#[error("line_offset must be a 1-indexed line number")]
InvalidLineOffset,
#[error("max_lines must be a positive integer")]
InvalidMaxLines,
#[error("line_offset exceeds file length")]
LineOffsetExceedsFileLength,
#[error("path '{path}' is not a file")]
NotFile { path: String },
#[error("queries must not be empty or contain empty strings")]
EmptyQuery,
#[error("all_within_lines.line_count must be a positive integer")]
InvalidMatchWindow,
#[error("I/O error while reading memories: {0}")]
Io(#[from] std::io::Error),
}
impl MemoriesBackendError {
pub fn invalid_filename(filename: impl Into<String>, reason: impl Into<String>) -> Self {
Self::InvalidFilename {
filename: filename.into(),
reason: reason.into(),
}
}
pub fn invalid_path(path: impl Into<String>, reason: impl Into<String>) -> Self {
Self::InvalidPath {
path: path.into(),View on GitHub (pinned to 339751715c)
Solutions
- Trim and filter queries before the call, and bail out early if nothing remains.
- Tokenize with split_whitespace() instead of split(' ').
- Reject empty searches at the UI boundary so they never reach the backend.
Example fix
// before
let queries: Vec<String> = input.split(',').map(str::to_string).collect();
backend.search(SearchMemoriesRequest { queries, .. }).await?;
// after
let queries: Vec<String> = input
.split(',')
.map(str::trim)
.filter(|s| !s.is_empty())
.map(str::to_string)
.collect();
if queries.is_empty() {
return Ok(empty_search_response());
}
backend.search(SearchMemoriesRequest { queries, .. }).await?; Defensive patterns
Strategy: validation
Validate before calling
// Rust - build query lists that can never trip EmptyQuery
fn sanitize_queries(raw: &str) -> Vec<String> {
raw.split(&[',', ' '][..])
.map(str::trim)
.filter(|s| !s.is_empty())
.map(str::to_string)
.collect()
}
let queries = sanitize_queries(&input);
if queries.is_empty() {
return Ok(empty_search_response());
} Type guard
// Rust - predicate mirroring the backend check (applied after trim)
fn queries_valid(queries: &[String]) -> bool {
!queries.is_empty() && queries.iter().all(|q| !q.trim().is_empty())
} Prevention
- Trim and filter query tokens before calling search().
- Use split_whitespace rather than split(' ') when tokenizing.
- Gate empty searches at the input boundary.
When it happens
Trigger: queries: vec![] ; a query list containing an empty string or a whitespace-only string such as ' '; splitting user input on a delimiter and keeping empty tokens; forwarding an empty search-box value.
Common situations: Search forms submitted blank; input.split(',') or split(' ') producing empty pieces; queries assembled from optional fields where every field was None.
Related errors
- all_within_lines.line_count must be a positive integer
- filename '{filename}' {reason}
- ad-hoc note must not be empty
- path '{path}' {reason}
- line_offset must be a 1-indexed line number
AI-assisted analysis of openai/codex@339751715c (2026-08-25).
Data as JSON: /api/errors/b3802eec0204e643.
Report an issue: GitHub.