openai/codex · error · MemoriesBackendError
ad-hoc note must not be empty
Error message
ad-hoc note must not be empty
What it means
MemoriesBackend::add_ad_hoc_note rejects note bodies that are empty. Notes must carry content; a blank note is treated as a caller bug and is not stored.
Source
Thrown at codex-rs/ext/memories/src/backend.rs:139
File,
Directory,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, JsonSchema)]
#[schemars(deny_unknown_fields)]
pub struct MemorySearchMatch {
pub path: String,
pub match_line_number: usize,
pub content_start_line_number: usize,
pub content: String,
pub matched_queries: Vec<String>,
}
#[derive(Debug, thiserror::Error)]
pub enum MemoriesBackendError {
#[error("filename '{filename}' {reason}")]
InvalidFilename { filename: String, reason: String },
#[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")]View on GitHub (pinned to 339751715c)
Solutions
- Check the note is non-empty after trimming before calling add_ad_hoc_note.
- Fix the upstream producer that generated empty notes.
- Return a validation message to the user instead of persisting nothing.
Example fix
// before
backend.add_ad_hoc_note(AddAdHocMemoryNoteRequest { filename, note: " ".into() }).await?;
// after
if note.trim().is_empty() {
return Err(MemoriesBackendError::EmptyAdHocNote.into());
}
backend.add_ad_hoc_note(AddAdHocMemoryNoteRequest { filename, note }).await?; Defensive patterns
Strategy: validation
Validate before calling
if request.note.trim().is_empty() {
return Err(MemoriesBackendError::EmptyAdHocNote.into());
} Type guard
fn non_empty_note(note: &str) -> bool {
!note.trim().is_empty()
} Prevention
- Trim and check note bodies at the UI boundary before submission.
- Skip persisting empty model-generated memories.
- Return a user-facing validation message instead of a backend error.
When it happens
Trigger: add_ad_hoc_note with an empty or whitespace-only note string.
Common situations: Form submitted without text; a model emitting an empty memory; input trimmed down to nothing before the call.
Related errors
- filename '{filename}' {reason}
- path '{path}' {reason}
- line_offset must be a 1-indexed line number
- max_lines must be a positive integer
- path '{path}' is not a file
AI-assisted analysis of openai/codex@339751715c (2026-08-25).
Data as JSON: /api/errors/789e3b85b1e3dccb.
Report an issue: GitHub.