{"record":{"id":"adf7689a910fb882","repo":"Hmbown/CodeWhale","slug":"workspace-scope-requires-a-workspace-id","errorCode":null,"errorMessage":"workspace scope requires a workspace id","messagePattern":"workspace scope requires a workspace id","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/native_memory.rs","lineNumber":210,"sourceCode":"            fs::write(&target, content)?;\n            self.reindex_file(&target)?;\n            Ok(true)\n        })\n    }\n\n    /// Append a reviewed note to the selected Markdown source and refresh its\n    /// index. The note is treated as data, never as an instruction.\n    pub fn remember(\n        &self,\n        scope: MemoryScope,\n        workspace_id: Option<&str>,\n        note: &str,\n    ) -> Result<MemoryHit> {\n        let note = normalize_note(note)?;\n        let path = match scope {\n            MemoryScope::Global => self.global_path(),\n            MemoryScope::Workspace => self.workspace_path(\n                workspace_id.ok_or_else(|| anyhow!(\"workspace scope requires a workspace id\"))?,\n            )?,\n        };\n        self.with_write_lock(|| {\n            ensure_memory_file(&path)?;\n            let before = fs::read_to_string(&path).unwrap_or_default();\n            let line_start = before.lines().count().saturating_add(2);\n            let mut file = OpenOptions::new()\n                .create(true)\n                .append(true)\n                .open(&path)\n                .with_context(|| format!(\"open memory source {}\", path.display()))?;\n            if !before.is_empty() && !before.ends_with('\\n') {\n                writeln!(file)?;\n            }\n            writeln!(file, \"\\n- {note}\")?;\n            file.sync_data()?;\n            self.reindex_file(&path)?;\n            let line_end = line_start;","sourceCodeStart":192,"sourceCodeEnd":228,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/433685b2024e7bc4c99e1e2e326bcad39b4d9d65/crates/tui/src/native_memory.rs#L192-L228","documentation":"NativeMemory::remember was called with MemoryScope::Workspace but no workspace_id. A workspace-scoped memory file path can only be derived from a workspace id, so the call is rejected before any write happens.","triggerScenarios":"Calling remember(scope: MemoryScope::Workspace, workspace_id: None, note) — the ok_or_else in the Workspace arm of the scope match fires.","commonSituations":"Tool invocation of remember from a context where no workspace/session id was resolved; caller hardcodes MemoryScope::Workspace without threading the id through; tests or scripts that exercise the memory API directly.","solutions":["Pass the current workspace id when calling remember.","Use MemoryScope::Global if the note is not workspace-specific.","Fix the upstream code that resolves workspace id so it does not yield None in workspace sessions.","Validate scope/id pairing at the tool boundary before invoking the memory API."],"exampleFix":"// before\nmemory.remember(MemoryScope::Workspace, None, \"note\")?;\n// after\nmemory.remember(MemoryScope::Workspace, Some(&workspace_id), \"note\")?;","handlingStrategy":"validation","validationCode":"// Resolve and check before calling\nlet ws = workspace_id.ok_or_else(|| anyhow!(\"remember: workspace id required for Workspace scope\"))?;\nmemory.remember(MemoryScope::Workspace, Some(&ws), note)?;","typeGuard":null,"tryCatchPattern":"match memory.remember(scope, workspace_id, note) {\n    Err(e) if e.to_string().contains(\"workspace scope requires\") => {\n        eprintln!(\"Pass a workspace id or use MemoryScope::Global: {e}\");\n    }\n    other => other?,\n}","preventionTips":["Pair scope and id at the tool boundary: Workspace always carries Some(id).","Default to Global scope when no workspace session is active.","Centralize scope resolution so callers cannot pass mismatched pairs.","Add a unit test asserting the Workspace+None combination errors early."],"tags":["memory","argument","workspace"],"backgroundTag":"missing-required-argument","analyzedSha":"433685b2024e7bc4c99e1e2e326bcad39b4d9d65","analyzedAt":"2026-09-15T12:24:24.634Z","contentChangedAt":"2026-09-15T12:24:24.634Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}