{"record":{"id":"d546c685e74c1a58","repo":"Hmbown/CodeWhale","slug":"workflow-tool-requires-approval-source-explicit","errorCode":null,"errorMessage":"workflow-tool requires --approval-source explicit-workflow-command","messagePattern":"workflow-tool requires --approval-source explicit-workflow-command","errorType":"error_code","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/tui/src/lib.rs","lineNumber":12224,"sourceCode":"        Ok(()) => Ok(()),\n        Err(error) => {\n            let _ = emit_exec_stream_event(&ExecStreamEvent::Error {\n                error: format!(\"{error:#}\"),\n            });\n            exit_workflow_tool_failure();\n        }\n    }\n}\n\nasync fn run_workflow_tool_command_inner(\n    cli: &Cli,\n    args: WorkflowToolArgs,\n    plugin_registry: std::sync::Arc<crate::plugins::PluginRegistry>,\n) -> Result<()> {\n    use crate::tools::spec::ToolSpec;\n\n    if args.approval_source != \"explicit-workflow-command\" {\n        bail!(\"workflow-tool requires --approval-source explicit-workflow-command\");\n    }\n    let input: serde_json::Value = serde_json::from_str(&args.input_json)\n        .context(\"--input-json must be a valid Workflow tool input object\")?;\n    if !input.is_object() {\n        bail!(\"--input-json must be a JSON object\");\n    }\n    if !input\n        .get(\"action\")\n        .and_then(serde_json::Value::as_str)\n        .is_some_and(|action| action.eq_ignore_ascii_case(\"run\"))\n    {\n        bail!(\"workflow-tool accepts only action=run\");\n    }\n\n    let workspace = resolve_workspace(cli);\n    let mut config = load_config_from_cli(cli)?;\n    merge_user_workspace_config(&mut config, cli.config.clone(), &workspace);\n    if let Ok(env_url) =","sourceCodeStart":12206,"sourceCodeEnd":12242,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/lib.rs#L12206-L12242","documentation":"The `workflow-tool` CLI command runs a Workflow tool spec directly, but only when invoked with an explicit approval source of `explicit-workflow-command`. This guard prevents arbitrary tool execution from being smuggled in under a non-workflow approval provenance.","triggerScenarios":"Calling `codewhale workflow-tool ...` with `--approval-source` set to anything other than `\"explicit-workflow-command\"` (or omitted).","commonSituations":"Scripts wiring the workflow-tool command into generic tool pipelines that pass their own approval-source value, or forgetting the flag entirely.","solutions":["Pass `--approval-source explicit-workflow-command` on the command line.","If this call is not part of an explicit workflow, use the normal tool invocation path instead of workflow-tool.","Fix wrapper scripts to hardcode the required approval-source constant."],"exampleFix":"// before\ncodewhale workflow-tool --input-json '{...}'\n// after\ncodewhale workflow-tool --approval-source explicit-workflow-command --input-json '{...}'","handlingStrategy":"validation","validationCode":"if [[ \"$approval_source\" != \"explicit-workflow-command\" ]]; then\n  echo \"refusing: workflow-tool requires --approval-source explicit-workflow-command\" >&2; exit 2\nfi\n","typeGuard":null,"tryCatchPattern":"// shell\nif ! codewhale workflow-tool --approval-source explicit-workflow-command --input-json \"$json\"; then\n  echo \"workflow tool invocation rejected\" >&2\nfi\n","preventionTips":["Hardcode the literal approval-source constant in wrapper scripts.","Only reach for workflow-tool when executing an explicit workflow command.","Keep this guard in mind when refactoring shared tool-invocation helpers."],"tags":["cli","approval","workflow","security"],"backgroundTag":"invalid-flag-value","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}