Skip to content

fix(templates): failed Template Add preview warns the Add may be partial - #198521

Merged
Patrick-Erichsen merged 1 commit into
openclaw:mainfrom
etzelm:fix/templates-add-preview-no-mutation
Nov 15, 2026
Merged

Patrick-Erichsen merged 1 commit into
openclaw:mainfrom
etzelm:fix/templates-add-preview-no-mutation

Conversation

@etzelm

@etzelm etzelm commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes: when openclaw templates add runs against a Gateway and the preview fails, the CLI says "The outcome may be partial; inspect the operation's status and the target before retrying", although a preview never changes anything.

User Impact

User impact: a failed preview now reports that no local mutation was attempted, so users retry or fix the Template instead of inspecting state for a partial Add that cannot exist.

Why This Change Was Made

The CLI routes Add through the Gateway that owns the state dir and treats any error reply without details.mutationAccepted: false as an unknown outcome. templates.add.plan is read-only but sent no marker on either failure branch. Both its UNAVAILABLE and its FORBIDDEN (Labs disabled) replies now carry mutationAccepted: false, as other read-only owner methods already do. Error codes and messages are unchanged.

Evidence

  • src/gateway/server-methods/templates-add.test.ts: new cases assert the marker on UNAVAILABLE for a ClawHub source error and a generic error; the existing "Labs switched off mid-request" case now also asserts it on FORBIDDEN. They fail on origin/main and pass with the fix.
  • pnpm exec vitest run src/gateway/server-methods/templates-add.test.ts src/cli/templates-cli.state-owner.test.ts: pass.
  • pnpm check:changed --base origin/main: everything passes except the dead export scan, which fails the same way on origin/main in files this PR does not touch.
  • Live run, openclaw templates add @etzelm/job-application-coordinator against an isolated Gateway (preview fails on an invalid manifest):
before: ... could not complete templates.add.plan ... The outcome may be partial; inspect the operation's status and the target before retrying. No local fallback was attempted.
after:  ... could not complete templates.add.plan ... No local mutation was attempted. Update the Gateway or fix authentication and retry. ...

Known gap: the "after" recovery text still suggests updating the Gateway or fixing authentication, which is the CLI's generic owner-refused wording. Changing that text is out of scope here.

- templates.add.plan is read-only, but its error reply carried no mutationAccepted marker.
- The owner-routed CLI therefore told users a failed preview "may be partial" and to inspect state before retrying.
- Mark preview failures with details.mutationAccepted false, as other read-only owner methods do.
@clawsweeper

clawsweeper Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
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.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: XS labels Nov 14, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary 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. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 14, 2026
@clawsweeper

clawsweeper Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Marks failed Template Add previews as having accepted no mutation so the CLI stops warning about a partial Add.

Example: Run openclaw templates add @etzelm/job-application-coordinator against an isolated Gateway when its manifest is invalid.

  • Before: The CLI warns that the outcome may be partial and asks the user to inspect state.
  • After: The CLI reports that no local mutation was attempted.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Useful, focused, and supported by matching live output and targeted regression assertions; broad CI validation remains incomplete.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The contributor's live output exercises the shipped templates add command against an isolated Gateway with an invalid manifest and shows the partial-Add warning replaced by the no-mutation diagnostic.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A rejected read-only preview incorrectly tells users that an Add may have partially changed their state.
Reason: Accurate outcome reporting avoids unnecessary state inspection and uses an established error contract without changing product policy.

Merge readiness

✅ Ready for maintainer review

This PR fixes a real misleading preview-failure warning with a focused change; no introduced correctness or security defect was found, but the required CI gate is not successful.

Priority: P2
Reviewed head: 1a5293cf551acee14a810633c5e2696d1d263517

Before merge

None.

Findings

None.

Agent review details

How this fits together

The Template planning Gateway handler resolves a published package and returns a preview or error; the CLI's state-owner adapter uses error details to distinguish rejected work from an uncertain mutation.

flowchart LR
  A[Templates CLI] --> B[State owner adapter]
  B --> C[Gateway preview handler]
  C --> D[Template planner]
  D --> E[ClawHub source preview]
  C --> F[Error with mutation marker]
  F --> B
Loading

Technical review

Best possible solution:

Keep the no-mutation marker at the existing Gateway preview owner and merge this focused repair after the required CI gate succeeds.

Do we have a high-confidence way to reproduce the issue?

Current-main source directly connects an unmarked preview failure to the partial-outcome warning, and the contributor supplies matching live before/after output; no target code was executed during this read-only review.

Is this the best way to solve the issue?

This is the smallest complete fix: the read-only preview owner supplies the existing outcome marker on both catch branches without changing apply semantics, introducing another owner, or adding configuration.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 9156de83fa53.

Provenance checked

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

PR surface

Source +2, Tests +15. Total +17 across 2 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 4 2 +2
Tests 1 16 1 +15
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 20 3 +17

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:

No label changes.

Label justifications:

  • P2: The bug causes misleading recovery advice in an advanced CLI workflow without losing state or preventing an otherwise valid Add.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Complete the required CI gate for the reviewed head.

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 13, 2026, 7:51 PM ET / November 14, 2026, 00:51 UTC.

@roboclaw-bot roboclaw-bot added the clawtributors PR from a clawtributor label Nov 14, 2026
@Patrick-Erichsen
Patrick-Erichsen merged commit cf0efb5 into openclaw:main Nov 15, 2026
131 of 132 checks passed
@Patrick-Erichsen

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 16, 2026
…claw#198521)

- templates.add.plan is read-only, but its error reply carried no mutationAccepted marker.
- The owner-routed CLI therefore told users a failed preview "may be partial" and to inspect state before retrying.
- Mark preview failures with details.mutationAccepted false, as other read-only owner methods do.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clawtributors PR from a clawtributor gateway Gateway runtime P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS 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.

3 participants