Skip to content

fix(cli): workflows run on default args when --args-json is not an object - #216

Merged
steipete merged 2 commits into
openclaw:mainfrom
KrasimirKralev:fix/run-args-json-object
Nov 14, 2026
Merged

steipete merged 2 commits into
openclaw:mainfrom
KrasimirKralev:fix/run-args-json-object

Conversation

@KrasimirKralev

@KrasimirKralev KrasimirKralev commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes: a workflow run with --args-json '["production"]' (or a string, number, boolean, null or an empty value) silently ignores what the caller passed, runs every step on its default args, and exits 0.

lobster graph already rejects the non-object values. lobster run only checks that the text parses as JSON, and workflows.run does the same, so a null there fails with Cannot 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_error in tool mode on lobster run; a runtime_error naming the flag on workflows.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-json on inline pipelines stays ignored, and openclaw.invoke --args-json is not changed: its value is the tool's own payload.

Why This Change Was Made

run, graph and workflows.run each parsed --args-json on their own, and only graph checked the shape. All three now go through one parseWorkflowArgsJson helper, so they use the same rule and the same messages (<command> --args-json must be a JSON object, and must be valid JSON for an empty value). The README states the rule next to the run example.

Regression tests cover run in human and tool mode (including that the step never executed), workflows.run, and graph. With the fix removed, the full suite goes from 746 pass to 743 pass and 3 fail: exactly the three new run, workflows.run and graph tests.

Evidence

Real CLI, Linux, Node 24, node bin/lobster.js built from source. Base is c19d3cf, branch is a760ca5. dep.lobster has one arg, target, with default staging, and one step, echo deploying to ${target}.

Command Base Branch
run --mode tool dep.lobster --args-json '["production"]' ok:true, deploying to staging, exit 0 parse_error, exit 2
run --mode tool dep.lobster --args-json '"production"' ok:true, deploying to staging, exit 0 parse_error, exit 2
run --mode tool dep.lobster --args-json 'null' ok:true, deploying to staging, exit 0 parse_error, exit 2
run dep.lobster --args-json '["production"]' prints deploying to staging, exit 0 run --args-json must be a JSON object, exit 2
run dep.lobster --args-json= prints deploying to staging, exit 0 run --args-json must be valid JSON, exit 2
run --mode tool dep.lobster --args-json '{"target":"production"}' deploying to production, exit 0 same
run --mode tool dep.lobster --args-json 'nope' run --args-json must be valid JSON, exit 2 same
run --mode tool "workflows.run --name github.pr.monitor --args-json 'null'" Cannot read properties of null (reading 'repo'), exit 1 workflows.run --args-json must be a JSON object, exit 1
graph dep.lobster --args-json '[1]' graph --args-json must be a JSON object, exit 2 same
Branch transcript
$ node bin/lobster.js run --mode tool dep.lobster --args-json '["production"]'
{"ok":false,"status":null,"output":null,"error":{"type":"parse_error","message":"run --args-json must be a JSON object"}}
exit=2
$ node bin/lobster.js run --mode tool dep.lobster --args-json '{"target":"production"}'
{"ok":true,"status":"ok","output":["deploying to production\n"],"error":null}
exit=0
$ node bin/lobster.js run dep.lobster --args-json '["production"]'
run --args-json must be a JSON object
exit=2
$ node bin/lobster.js run dep.lobster --args-json=
run --args-json must be valid JSON
exit=2
$ node bin/lobster.js run --mode tool "workflows.run --name github.pr.monitor --args-json 'null'"
{"ok":false,"error":{"type":"runtime_error","message":"workflows.run --args-json must be a JSON object"}}
exit=1

The --mode tool lines above are filtered through jq -c '{ok,status,output,error}' to fit on one line.

pnpm lint, pnpm typecheck and pnpm test pass (746 of 746).

Not tested: the embedded OpenClaw runner, which parses argsJson itself and calls runToolRequest directly, so this change does not reach it. No Windows run.

@clawsweeper

clawsweeper Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-07T06:52:32.195917Z a760ca5 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread README.md Outdated
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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. P2 Normal priority bug or improvement with limited blast radius. proof: sufficient Contributor real behavior proof is sufficient. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 7, 2026
@clawsweeper

clawsweeper Bot commented Nov 7, 2026

Copy link
Copy Markdown

Codex review: needs maintainer review before merge.

What this changes

This 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"]'.

  • Before: The workflow prints deploying to staging and exits successfully.
  • After: The CLI reports that --args-json must be a JSON object and exits 2 before executing the workflow.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Focused bug fix with shipped CLI evidence, meaningful regression coverage, passing exact-head checks, and no open findings; persisted formats and valid argument objects remain unchanged.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The contributor's reviewed-head Linux Node 24 transcript exercises the shipped bin/lobster.js entry point through run and workflows.run, showing invalid-shape and empty-value rejection alongside successful valid-object execution.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A caller can supply malformed workflow arguments and receive a successful execution using unintended defaults.
Reason: Rejecting invalid argument shapes restores the named-argument contract already enforced by graph; the compatibility change is limited to malformed inputs and is documented.

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
Reviewed head: a760ca5a615857f836fa7486ab8fc5450074b33a

Before merge

None.

Findings

None.

Agent review details

How this fits together

CLI 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]
Loading

Technical review

Best 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

  • Workflow-file argument parsing changes intended behavior with a stated reason (14479b6: The workflow-file feature parsed JSON before passing arguments into workflow execution; its examples use named object arguments.)
  • Named workflow argument parsing changes intended behavior with a stated reason (121d61c: The named-workflow command accepted JSON text for workflow argument objects without a shape check.)
  • Graph argument validation changes intended behavior with a stated reason (7d6a22a: Graph rendering introduced object-shape validation; this PR preserves that rule and explicitly extends rejection to empty supplied values.)
  • CLI error reporting and shared value helpers keeps the original intent (fix: route CLI target errors and graph help correctly #178: Mode-aware parse errors were centralized, while refactor: separate workflow dry runs and value resolution #173 extracted value helpers without changing resolution behavior.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 25aaf32 adds src/workflows/values.ts:9 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 25aaf32ee2fc; files: src/workflows/values.ts)
  • Vignesh Natarajan: Raw commit 121d61c adds src/commands/workflows/workflows_run.js:5 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 121d61c4163f; files: src/commands/workflows/workflows_run.js)

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

  • add P2: Malformed workflow arguments can silently select defaults, but the failure is limited to callers supplying invalid input shapes.
  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: Malformed workflow arguments can silently select defaults, but the failure is limited to callers supplying invalid input shapes.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 7, 2026, 2:13 AM ET / 07:13 UTC.

@steipete
steipete merged commit edf74e0 into openclaw:main Nov 14, 2026
9 checks passed
@steipete

Copy link
Copy Markdown
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal priority bug or improvement with limited blast radius. proof: sufficient Contributor real behavior proof is sufficient. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants