Hmbown/CodeWhale · error
workspace scope requires a workspace id
Error message
workspace scope requires a workspace id
What it means
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.
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.
Example fix
// before memory.remember(MemoryScope::Workspace, None, "note")?; // after memory.remember(MemoryScope::Workspace, Some(&workspace_id), "note")?;
Defensive patterns
Strategy: validation
Validate before calling
// Resolve and check before calling
let ws = workspace_id.ok_or_else(|| anyhow!("remember: workspace id required for Workspace scope"))?;
memory.remember(MemoryScope::Workspace, Some(&ws), note)?; Try / catch
match memory.remember(scope, workspace_id, note) {
Err(e) if e.to_string().contains("workspace scope requires") => {
eprintln!("Pass a workspace id or use MemoryScope::Global: {e}");
}
other => other?,
} Prevention
- 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.
When it happens
Trigger: Calling remember(scope: MemoryScope::Workspace, workspace_id: None, note) — the ok_or_else in the Workspace arm of the scope match fires.
Common situations: 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.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- workspace memory requires a git repository with an origin
- workspace scope requires an id
- --app must be `web` or `headless`, got
- AutomationEditorInvalidWorkspace
- Cargo metadata contains duplicate workspace package names
AI-assisted analysis of Hmbown/CodeWhale@433685b202 (2026-09-15).
Data as JSON: /api/errors/adf7689a910fb882.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/src/native_memory.rs:210
fs::write(&target, content)?;
self.reindex_file(&target)?;
Ok(true)
})
}
/// Append a reviewed note to the selected Markdown source and refresh its
/// index. The note is treated as data, never as an instruction.
pub fn remember(
&self,
scope: MemoryScope,
workspace_id: Option<&str>,
note: &str,
) -> Result<MemoryHit> {
let note = normalize_note(note)?;
let path = match scope {
MemoryScope::Global => self.global_path(),
MemoryScope::Workspace => self.workspace_path(
workspace_id.ok_or_else(|| anyhow!("workspace scope requires a workspace id"))?,
)?,
};
self.with_write_lock(|| {
ensure_memory_file(&path)?;
let before = fs::read_to_string(&path).unwrap_or_default();
let line_start = before.lines().count().saturating_add(2);
let mut file = OpenOptions::new()
.create(true)
.append(true)
.open(&path)
.with_context(|| format!("open memory source {}", path.display()))?;
if !before.is_empty() && !before.ends_with('\n') {
writeln!(file)?;
}
writeln!(file, "\n- {note}")?;
file.sync_data()?;
self.reindex_file(&path)?;
let line_end = line_start;View on GitHub (pinned to 433685b202)