{"record":{"id":"1f36eb853d551872","repo":"openai/codex","slug":"ad-hoc-note-filename-already-exists","errorCode":null,"errorMessage":"ad-hoc note '{filename}' already exists","messagePattern":"ad-hoc note '(.+?)' already exists","errorType":"validation","errorClass":"MemoriesBackendError","httpStatus":null,"severity":"error","filePath":"codex-rs/ext/memories/src/backend.rs","lineNumber":141,"sourceCode":"}\n\n#[derive(Debug, Clone, PartialEq, Eq, Serialize, JsonSchema)]\n#[schemars(deny_unknown_fields)]\npub struct MemorySearchMatch {\n    pub path: String,\n    pub match_line_number: usize,\n    pub content_start_line_number: usize,\n    pub content: String,\n    pub matched_queries: Vec<String>,\n}\n\n#[derive(Debug, thiserror::Error)]\npub enum MemoriesBackendError {\n    #[error(\"filename '{filename}' {reason}\")]\n    InvalidFilename { filename: String, reason: String },\n    #[error(\"ad-hoc note must not be empty\")]\n    EmptyAdHocNote,\n    #[error(\"ad-hoc note '{filename}' already exists\")]\n    AdHocNoteAlreadyExists { filename: String },\n    #[error(\"path '{path}' {reason}\")]\n    InvalidPath { path: String, reason: String },\n    #[error(\"cursor '{cursor}' {reason}\")]\n    InvalidCursor { cursor: String, reason: String },\n    #[error(\"path '{path}' was not found\")]\n    NotFound { path: String },\n    #[error(\"line_offset must be a 1-indexed line number\")]\n    InvalidLineOffset,\n    #[error(\"max_lines must be a positive integer\")]\n    InvalidMaxLines,\n    #[error(\"line_offset exceeds file length\")]\n    LineOffsetExceedsFileLength,\n    #[error(\"path '{path}' is not a file\")]\n    NotFile { path: String },\n    #[error(\"queries must not be empty or contain empty strings\")]\n    EmptyQuery,\n    #[error(\"all_within_lines.line_count must be a positive integer\")]","sourceCodeStart":123,"sourceCodeEnd":159,"githubUrl":"https://github.com/openai/codex/blob/339751715c64496cb86246bfb3935f40e309dd3d/codex-rs/ext/memories/src/backend.rs#L123-L159","documentation":"MemoriesBackend::add_ad_hoc_note refuses to overwrite: creating a note whose filename already exists in the memory store fails. Ad-hoc notes are create-only at this layer; there is no in-place update path.","triggerScenarios":"add_ad_hoc_note with a filename already present in the store — from a previous call, a synced store, or a replayed request.","commonSituations":"Retrying a call after a timeout without changing the filename; two writers racing to create the same note; attempting to 'update' by re-adding.","solutions":["Choose a different (e.g. suffixed) filename for the new note.","If updating was intended, read the existing note and store the edited version under a new name.","On retries, treat AlreadyExists as success-by-idempotency when appropriate."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match backend.add_ad_hoc_note(request).await {\n    Err(MemoriesBackendError::AdHocNoteAlreadyExists { filename }) => {\n        tracing::info!(%filename, \"note already present; treating replay as idempotent\");\n        Ok(AddAdHocMemoryNoteResponse {})\n    }\n    r => r,\n}","preventionTips":["Suffix filenames (timestamp or counter) when creating similar notes.","On client retries, map AlreadyExists to success when the operation is idempotent.","Do not attempt in-place updates through add_ad_hoc_note — it is create-only."],"tags":["rust","memories","duplicate","codex"],"backgroundTag":"duplicate-entry","analyzedSha":"339751715c64496cb86246bfb3935f40e309dd3d","analyzedAt":"2026-08-25T05:35:09.876Z","schemaVersion":2},"datasetVersion":"2026-08-25T06:17:31.827Z"}