{"record":{"id":"f4f55729c17ddba4","repo":"Hmbown/CodeWhale","slug":"task-expected-an-options-object","errorCode":null,"errorMessage":"task(): expected an options object","messagePattern":"task\\(\\): expected an options object","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"crates/workflow-js/src/vm.rs","lineNumber":1062,"sourceCode":"  // Capture temporary host bindings into this closure, then strip them from\n  // globalThis so scripts only see the documented Workflow surface (#4129).\n  const hostTask = __workflow_task;\n  const hostLog = __workflow_log;\n  const hostPhase = __workflow_phase;\n  const hostBudgetTotal = __workflow_budget_total;\n  const hostBudgetSpent = __workflow_budget_spent;\n  const hostBudgetRemaining = __workflow_budget_remaining;\n\n  const MAX_ITEMS = __MAX_ITEMS__;\n  const taskErrorText = (err) => String(err && err.message !== undefined ? err.message : err);\n  const isFatalTaskError = (err) => {\n    const text = taskErrorText(err);\n    return text.includes(\"responseSchema\") || text.includes(\"run cancelled\");\n  };\n\n  globalThis.task = async (opts) => {\n    if (opts === null || typeof opts !== \"object\") {\n      throw new TypeError(\"task(): expected an options object\");\n    }\n    const envelope = JSON.parse(await hostTask(JSON.stringify(opts)));\n    if (envelope.error !== undefined) {\n      throw new Error(envelope.error);\n    }\n    return envelope.value;\n  };\n\n  globalThis.parallel = (thunks) => {\n    if (!Array.isArray(thunks)) {\n      throw new TypeError(\"parallel(): expected an array of thunks\");\n    }\n    if (thunks.length > MAX_ITEMS) {\n      throw new Error(\"parallel(): max \" + MAX_ITEMS + \" items per call\");\n    }\n    return Promise.all(thunks.map((thunk) => {\n      try {\n        return Promise.resolve(typeof thunk === \"function\" ? thunk() : thunk).catch((err) => {","sourceCodeStart":1044,"sourceCodeEnd":1080,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/8880682c63083a91624de936797efa3ce9e498fd/crates/workflow-js/src/vm.rs#L1044-L1080","documentation":"Raised by NativeMemoryStore::delete_all when asked to wipe workspace-scoped memory without identifying which workspace. Because each workspace has its own directory under root/workspace/<sha256-of-origin>/, a Workspace deletion with workspace_id=None is ambiguous and the store refuses rather than deleting every workspace or none. The command layer resolves this by first calling workspace_id(cwd); when that returns None it reports that there is nothing workspace-scoped to delete.","triggerScenarios":"store.delete_all(Some(MemoryScope::Workspace), None) — e.g. a `/memory erase workspace` command executed in a directory with no git origin, or API misuse passing None explicitly.","commonSituations":"Users running memory-erase commands outside a git repo; repos without an origin remote; automation calling delete_all with a scope filter but forgetting the id argument.","solutions":["Resolve the id and handle the None case as a no-op, matching commands/groups/memory/memory.rs: if workspace_id(cwd)? is None, report 'no workspace memory for this directory' and skip deletion.","Add an origin remote if the workspace memory you want to erase belongs to this checkout: git remote add origin <url>.","To erase everything including all workspaces, call delete_all(None, None) instead of guessing a scope."],"exampleFix":"// before\nstore.delete_all(Some(MemoryScope::Workspace), None)?;\n\n// after\nmatch NativeMemoryStore::workspace_id(&cwd)? {\n    Some(id) => store.delete_all(Some(MemoryScope::Workspace), Some(&id))?,\n    None => {} // no origin remote: nothing workspace-scoped to delete\n}","handlingStrategy":"validation","validationCode":"match NativeMemoryStore::workspace_id(&cwd)? {\n    Some(id) => store.delete_all(Some(MemoryScope::Workspace), Some(&id))?,\n    None => { /* nothing workspace-scoped here; no-op */ }\n}","typeGuard":null,"tryCatchPattern":"match store.delete_all(Some(MemoryScope::Workspace), ws_id) {\n    Ok(()) => {}\n    Err(e) if e.to_string().contains(\"workspace scope requires a workspace id\") => {\n        eprintln!(\"no workspace memory for this directory (no git origin remote)\");\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Resolve the id before offering a 'delete workspace memory' action in UI/CLI.","Treat delete_all(Workspace, None) as a programming error — assert the invariant in debug builds.","For destructive commands, prefer explicit ids resolved from cwd over caller-supplied scope strings."],"tags":["rust","native-memory","workspace","deletion","validation"],"backgroundTag":null,"analyzedSha":"8880682c63083a91624de936797efa3ce9e498fd","analyzedAt":"2026-08-16T11:31:27.956Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}