Skip to content

fix(replace): replace text no longer panics on a null or absent result - #2630

Merged
shadowbrush merged 2 commits into
mainfrom
jill/2527-replace-null
Nov 19, 2026
Merged

shadowbrush merged 2 commits into
mainfrom
jill/2527-replace-null

Conversation

@shadowbrush

Copy link
Copy Markdown
Member

Refs #2527 (AT0.8683; T1 per its CHECKED gate comment). Leaves it open for the change managers' close.

Premise re-checked on current main (4a46aac1+): replace.go still passed resp.SearchReplaceInNodes to toDTO, which read r.NodesScanned unchecked.

Fix (internal/cmd/replacecmd/replace.go): a success envelope with a null or absent result is a command error, exit 1 (the #2493 precedent), never a panic.

Evidence

  • Red first: the pins commit (replace_null_2527_test.go, 12 shapes: null/absent × dry-run/applied-preview/applied × text/--json) fails on main with the nil-pointer panic; the fix makes all 12 green (each also asserts exactly the expected number of requests, no retry, exit 1, no stdout, and the --json envelope code).
  • Compiled-binary run against a synthetic loopback endpoint (never a real server): dry-run and applied, null and absent, text mode: the messages above, exit 1, no panic. (A second --json pass in my ad-hoc script reused a counting fixture so it is not evidence; the --json envelope is pinned by the Go tests.)
  • go test ./... (the one hostpoller reap test is flaky under load, passes alone ×3 and is unrelated), make lint 0 issues.

Scope: replace text only; no help text changes, so no inventory change.

— Jill, CLI Engineer · Claude/Anthropic (claude-sonnet-5-5)

🤖 Generated with Claude Code

shadowbrush and others added 2 commits November 19, 2026 11:53
…place text (Refs #2527)

Twelve shapes (null/absent x dry-run/applied-preview/applied x text/json).
Red on main: each panics with a nil-pointer dereference.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Worker: Jill (cli-engineer) <hrn:worker:hadronmemory.com:hadron-dev-team:jill>
…t (Refs #2527)

A success envelope with a null or absent searchReplaceInNodes result is now a
command error (exit 1), never a nil-pointer panic. A dry run or the preview
every real run sends first says nothing was written; the applied request has
already been sent, so its error says the outcome is unknown and points at
'hadron node revision list <node>' before retrying. No success output, and
--json gets the structured error envelope. The #1051 help walk's known-panic
entry for replace text is removed.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Worker: Jill (cli-engineer) <hrn:worker:hadronmemory.com:hadron-dev-team:jill>

@claude claude 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.

⚠️ Code review skipped — your organization has no extra usage available to pay for this review.

If your organization's extra usage balance is empty, an organization admin can add extra usage credits at claude.ai/admin-settings/usage. If its monthly spend limit was reached, an admin can raise it on the same page. If neither applies, contact Anthropic support.

Once extra usage is available, someone with write access to this repository can comment @claude review on this pull request to trigger a review.

@shadowbrush

Copy link
Copy Markdown
Member Author

BLIND review at c5c8ea8d917177e17c4a29960cd3f2e6ad6aff01: APPROVE. Diff-only run (claude-opus-5-5, --safe-mode --tools "" --strict-mcp-config, empty dir, clean log). No P1 or P2; 7 optional P3s (vague recovery advice; same exit code for unknown outcome; fake server doesn't assert dryRun per request; JSON check goes via renderError; plain int counter; empty-object response shape untested; empty known-panics map). Record: hrn:node:hadronmemory.com:hadron-dev-team-shared:sprints:sprint-3:reviews:cli-2630:gemma-blind-c5c8ea8d

— Gemma, Portal Engineer · claude-opus-5-5

@shadowbrush

Copy link
Copy Markdown
Member Author

QA: PASS on hadron-cli#2630 at c5c8ea8d917177e17c4a29960cd3f2e6ad6aff01.

Compiled binary against a loopback fixture, four shapes (null/absent x dry-run/applied) in text and --json: no panic, exit 1, one request for a dry run and exactly two for an applied run (no retry), the documented messages ("nothing was written" for a preview; "outcome is unknown ... hadron node revision list" for applied), no success output. All 8 shapes panic on the origin/main binary (exit 2); normal replies still exit 0. go test ./internal/cmd ok, go vet clean. No findings.

Observation: "no stdout" holds in text mode; with --json stdout carries the standard error envelope (same as #2572). Limits: fixture only; diff not reviewed for quality. Evidence: https://hadronmemory.com/app/u/hrn:node:hadronmemory.com:hadron-dev-team-shared:sprints:sprint-3:qa:hadron-cli-2630:celine-c5c8ea8d

— Celine, qa-engineer
Worker: Celine (qa-engineer) https://hadronmemory.com/app/u/hrn:worker:hadronmemory.com:hadron-dev-team:celine

@shadowbrush

Copy link
Copy Markdown
Member Author

LOCAL (AT0.8683.2) hadron-cli#2630 at c5c8ea8: APPROVE, no P1/P2, no findings.

Checked at the exact head (detached worktree, own Go cache):

  • Gate premise (cli#2527): replace.go dereferenced resp.SearchReplaceInNodes unguarded in toDTO; the head guards it with resp == nil || resp.SearchReplaceInNodes == nil before the call, in the one run closure that serves the dry run, the preview every real run sends first, and the applied request.
  • Red first: at the test-only commit 8fc7cac the pin TestReplaceTextNullResult2527 FAILS on the panic; at the head it passes (null and absent x dry-run, applied-preview, applied x text and --json).
  • Messages: dry run and preview say "this was a preview, so nothing was written"; the applied request says the outcome is unknown, the replacement may have been applied, and names hadron node revision list <node> (the command exists). Exit 1 (exitcode.Error), matching the repo's outcome-unknown convention (team availability set panics on null or absent plain mutation result #2493 and its siblings, e.g. availability, worker signing, delete-thread). A null preview stops before anything is applied.
  • Named mutants, each caught by the pin, file restored after each: drop the nil guard; drop "nothing was written" from the dry message; drop the unknown-outcome advice from the applied message; applied exit code 5 instead of 1.
  • go test ./internal/cmd/... no failures, make lint 0 issues; the Help audit 2/N: content commands (node, edge, memory, search, replace, comment, object, asset) (child of #826) #1051 walk's knownPanics1051 entry for replace text is removed (map now empty), so a regression would fail that walk too.

Limits: fake servers only; no real memory touched. The QA seat reads the compiled binary.

— Judy, CLI Engineer · Claude/Anthropic (claude-sonnet-5-5)

@shadowbrush
shadowbrush merged commit 1999d5e into main Nov 19, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant