Repository navigation
fix(cli): workflows run on default args when --args-json is not an object - #216
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b82319e551
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| lobster run --file path/to/workflow.lobster --args-json '{"tag":"family"}' | ||
| ``` | ||
|
|
||
| `--args-json` must be a JSON object. Anything else (an array, a string, `null`) is an input error (exit code 2, `parse_error` in tool mode) and no step runs. |
There was a problem hiding this comment.
Reject explicitly empty args JSON
When --args-json= is passed (or --args-json "$EMPTY" with an empty variable), parseRunArgs leaves argsJson empty/null and the truthiness guard in handleRun at src/cli.ts:205 skips the new parser, so a successful workflow can still execute with default arguments and exit 0. This makes the new “anything else ... no step runs” contract false for a common missing-input case and preserves the same silent-default hazard; track whether the option was supplied and validate even an empty string.
Useful? React with 👍 / 👎.
|
Codex review: needs maintainer review before merge. What this changesThis PR rejects empty or non-object workflow argument JSON before execution and shares validation across run, graph, and workflows.run. Example: Run dep.lobster with target defaulting to staging and --args-json '["production"]'.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR fixes a current CLI input-validation bug that remains on main; no actionable correctness or security defect was found in the reviewed patch. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherCLI and named-workflow commands parse caller-supplied JSON into argument records, which workflow execution uses to resolve defaults and run steps. flowchart TD
A[CLI arguments] --> B[Run or graph command]
C[Named workflow command] --> D[Shared JSON validation]
B --> D
D --> E[Input error]
D --> F[Workflow argument record]
F --> G[Workflow execution or graph rendering]
Technical reviewBest possible solution: Use the shared validator at the existing command boundaries while preserving valid object arguments, omitted-argument defaults, and existing error envelopes. Do we have a high-confidence way to reproduce the issue? Current-main source shows unchecked JSON reaching default resolution, and the contributor supplies matching before-and-after CLI output; no target code was executed during this review. Is this the best way to solve the issue? The shared parser is a focused fix at the existing input owners, preserves supported object inputs, and avoids adding a competing execution path. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against c19d3cf481e9. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 7, 2026, 2:13 AM ET / 07:13 UTC. |
|
Merged in edf74e0. Reproduced on the built baseline CLI: an array supplied as workflow arguments ran with the default target; the patched CLI rejects it with exit 2 and a parse_error, while valid object arguments still succeed. Validation: focused CLI argument tests (4/4), then Linux Node 24 build, doctor, lint, typecheck, and full tests (746/746). Node 22 and Node 24 PR CI passed at a760ca5: https://github.com/openclaw/lobster/actions/runs/42348741849. Independent review found no actionable P0–P2 issues. Thanks @KrasimirKralev. |
What Problem This Solves
Fixes: a workflow run with
--args-json '["production"]'(or a string, number, boolean,nullor an empty value) silently ignores what the caller passed, runs every step on its default args, and exits 0.lobster graphalready rejects the non-object values.lobster runonly checks that the text parses as JSON, andworkflows.rundoes the same, so anullthere fails withCannot read properties of null (reading 'repo').User Impact
User impact: a caller that passes the wrong JSON shape now gets an input error before any step runs, instead of a successful run against the default values (exit code 2 and
parse_errorin tool mode onlobster run; aruntime_errornaming the flag onworkflows.run).Compatibility: a script that passes a non-object today and relies on the defaults will now fail. Those values were never used as args. JSON objects and invalid JSON behave as before.
graph --args-json=used to fall back to no args and now fails too, so all three commands treat an empty value the same way.--args-jsonon inline pipelines stays ignored, andopenclaw.invoke --args-jsonis not changed: its value is the tool's own payload.Why This Change Was Made
run,graphandworkflows.runeach parsed--args-jsonon their own, and onlygraphchecked the shape. All three now go through oneparseWorkflowArgsJsonhelper, so they use the same rule and the same messages (<command> --args-json must be a JSON object, andmust be valid JSONfor an empty value). The README states the rule next to therunexample.Regression tests cover
runin human and tool mode (including that the step never executed),workflows.run, andgraph. With the fix removed, the full suite goes from 746 pass to 743 pass and 3 fail: exactly the three newrun,workflows.runandgraphtests.Evidence
Real CLI, Linux, Node 24,
node bin/lobster.jsbuilt from source. Base isc19d3cf, branch isa760ca5.dep.lobsterhas one arg,target, with defaultstaging, and one step,echo deploying to ${target}.run --mode tool dep.lobster --args-json '["production"]'ok:true,deploying to staging, exit 0parse_error, exit 2run --mode tool dep.lobster --args-json '"production"'ok:true,deploying to staging, exit 0parse_error, exit 2run --mode tool dep.lobster --args-json 'null'ok:true,deploying to staging, exit 0parse_error, exit 2run dep.lobster --args-json '["production"]'deploying to staging, exit 0run --args-json must be a JSON object, exit 2run dep.lobster --args-json=deploying to staging, exit 0run --args-json must be valid JSON, exit 2run --mode tool dep.lobster --args-json '{"target":"production"}'deploying to production, exit 0run --mode tool dep.lobster --args-json 'nope'run --args-json must be valid JSON, exit 2run --mode tool "workflows.run --name github.pr.monitor --args-json 'null'"Cannot read properties of null (reading 'repo'), exit 1workflows.run --args-json must be a JSON object, exit 1graph dep.lobster --args-json '[1]'graph --args-json must be a JSON object, exit 2Branch transcript
The
--mode toollines above are filtered throughjq -c '{ok,status,output,error}'to fit on one line.pnpm lint,pnpm typecheckandpnpm testpass (746 of 746).Not tested: the embedded OpenClaw runner, which parses
argsJsonitself and callsrunToolRequestdirectly, so this change does not reach it. No Windows run.