{"record":{"id":"30d7ea62b5080026","repo":"xai-org/grok-build","slug":"clear-failed","errorCode":null,"errorMessage":"clear failed","messagePattern":"clear failed","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codegen/xai-grok-pager/src/memory_cmd.rs","lineNumber":128,"sourceCode":"            Err(e) => {\n                errors.push(format!(\"{}: {e}\", t.label));\n            }\n        }\n    }\n\n    if cleared && errors.is_empty() {\n        println!(\"Memory cleared.\");\n    } else if cleared {\n        println!(\"Memory partially cleared. Errors:\");\n        for e in &errors {\n            eprintln!(\"  {e}\");\n        }\n    } else if !errors.is_empty() {\n        eprintln!(\"Failed to clear memory:\");\n        for e in &errors {\n            eprintln!(\"  {e}\");\n        }\n        return Err(anyhow::anyhow!(\"clear failed\"));\n    }\n\n    Ok(())\n}\n","sourceCodeStart":110,"sourceCodeEnd":133,"githubUrl":"https://github.com/xai-org/grok-build/blob/bc7f02eddd3d84085849dc19ed216f11c23b0571/crates/codegen/xai-grok-pager/src/memory_cmd.rs#L110-L133","documentation":"run_clear deletes memory files for each ClearTarget and collects per-target errors. If every target's clear closure returned an error (nothing cleared and errors non-empty), it prints the details to stderr and returns the generic anyhow error \"clear failed\". The library throws it as a summary sentinel: the specifics (label + underlying error per target) are printed above it, not embedded in the error value.","triggerScenarios":"Invoking the memory clear command where at least one target exists but every target's (t.clear)(storage) call fails — e.g. storage backends erroring, permission denied on memory files, lock/IO failures — with zero targets succeeding.","commonSituations":"Read-only filesystem or files owned by another user; corrupted memory storage; another process holding the memory store; running clear in an environment (container/CI) without write access to the memory directory.","solutions":["Check stderr directly above the error: each failing target prints \"label: <underlying error>\"; fix the cause listed there.","Fix file permissions on the memory directory/files (chown/chmod) so the clear closures can delete them.","Close other processes using the memory store and retry.","Run with the specific scope/target so the failure is isolated, and verify disk space/IO health."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"fn clearable(t: &ClearTarget) -> bool {\n    t.path.exists() && std::fs::metadata(&t.path).map(|m| !m.permissions().readonly()).unwrap_or(false)\n}\n// skip or warn on targets that exist but aren't writable before calling the clear command","typeGuard":null,"tryCatchPattern":"// the error is a generic summary; capture stderr for the real causes\nmatch memory_clear_run(...) {\n    Err(e) if e.to_string() == \"clear failed\" => {\n        eprintln!(\"all memory targets failed to clear; see per-target errors above\");\n        // fall back to manual cleanup: delete the listed memory files yourself\n    }\n    Err(e) => return Err(e),\n    Ok(()) => {}\n}","preventionTips":["Run the clear command as a user with write access to the memory directory.","Close other sessions/processes that may lock the memory store.","Check filesystem writability (and disk space) in containers/CI before clearing.","Read the per-target stderr lines; they identify the exact failing scope."],"tags":["filesystem","memory","cli","permissions"],"backgroundTag":"file-delete-failed","analyzedSha":"bc7f02eddd3d84085849dc19ed216f11c23b0571","analyzedAt":"2026-08-31T04:59:42.031Z","schemaVersion":2},"datasetVersion":"2026-08-31T09:17:48.483Z"}