{"record":{"id":"694ab3c31b83a1e9","repo":"tinyhumansai/openhuman","slug":"missing-workspace","errorCode":null,"errorMessage":"missing --workspace","messagePattern":"missing --workspace","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src/core/subconscious_cli.rs","lineNumber":233,"sourceCode":"            \"interval_minutes\": mode.default_interval_minutes().max(5),\n        });\n\n        println!(\"{}\", serde_json::to_string_pretty(&status)?);\n        Ok(())\n    })\n}\n\n// ── helpers ────────────────────────────────────────────────────────────────\n\nfn parse_workspace_flag(args: &[String]) -> Result<Option<PathBuf>> {\n    let mut workspace: Option<PathBuf> = None;\n    let mut i = 0;\n    while i < args.len() {\n        match args[i].as_str() {\n            \"--workspace\" | \"-w\" => {\n                workspace = Some(PathBuf::from(\n                    args.get(i + 1)\n                        .ok_or_else(|| anyhow!(\"missing --workspace\"))?,\n                ));\n                i += 2;\n            }\n            other => return Err(anyhow!(\"unknown flag '{other}'\")),\n        }\n    }\n    Ok(workspace)\n}\n\nfn is_help(s: &str) -> bool {\n    matches!(s, \"--help\" | \"-h\" | \"help\")\n}\n\nfn print_help() {\n    eprintln!(\n        \"Usage: openhuman subconscious <command> [options]\n\nCommands:","sourceCodeStart":215,"sourceCodeEnd":251,"githubUrl":"https://github.com/tinyhumansai/openhuman/blob/a221052e0df5b1f7598fceba7329fd1af95d6699/src/core/subconscious_cli.rs#L215-L251","documentation":"Flag parser `parse_workspace_flag` (src/core/subconscious_cli.rs:233) requires a value after `--workspace` / `-w`; when the flag is the last token, `args.get(i + 1)` is None and this error fires. It is purely positional — a value that begins with `--` would still be consumed as the value.","triggerScenarios":"`openhuman subconscious status --workspace` (no path after), or `-w` at end of args; also a shell script where the workspace variable expanded to nothing and the flag was left dangling.","commonSituations":"Empty `$WORKSPACE` env var in scripts (`-w \"$WORKSPACE\"` with WORKSPACE unset still passes an empty string — the dangling-flag case is when the argument list itself ends); truncated command lines from copy-paste; CI matrix jobs where the workspace param is optional and was omitted without removing the flag.","solutions":["Supply the path: `--workspace /path/to/dir` or `-w /path/to/dir`.","In scripts, guard: only append the flag when the variable is non-empty (`[ -n \"$WS\" ] && set -- \"$@\" --workspace \"$WS\"`).","If you did not intend to set a workspace, drop the flag — the default workspace from config is used."],"exampleFix":"# before\nopenhuman subconscious status --workspace\n# after\nopenhuman subconscious status --workspace ~/.openhuman/users/me","handlingStrategy":"validation","validationCode":"// Script-level guard: only append the flag when a value exists\n// POSIX sh:\n//   [ -n \"$WS\" ] && set -- \"$@\" --workspace \"$WS\"\n// Rust builder:\nlet mut cmd = Command::new(bin);\nif let Some(ws) = workspace.filter(|s| !s.trim().is_empty()) {\n    cmd.arg(\"--workspace\").arg(ws);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pair --workspace/-w with a literal value in the same statement.","Quote and check optional variables before injecting flags into CLI invocations."],"tags":["rust","cli","argument-validation","flag-parsing"],"backgroundTag":null,"analyzedSha":"a221052e0df5b1f7598fceba7329fd1af95d6699","analyzedAt":"2026-08-16T12:47:06.542Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}