Skip to content

fix(remote): say why bridge verification failed instead of only HTTP 500/502 - #353

Merged
devswha merged 2 commits into
mainfrom
fix/bridge-verify-errors
Oct 2, 2026
Merged

devswha merged 2 commits into
mainfrom
fix/bridge-verify-errors

Conversation

@devswha

@devswha devswha commented Oct 2, 2026

Copy link
Copy Markdown
Owner

What happened

Adding or reconnecting a remote PC whose herdr is not running showed only Bridge verification failed (500). Reconnect after checking the remote bridge. (or (502)), so nothing told the person what to check on that PC.

Cause

  • server/bridge.ts bridgeIdentity() ran statSync(socket) unguarded: a missing socket (on Windows, marker) left as a plain ENOENT, which errorResponse turns into 500 internal_error with the absolute path in its message.
  • server/machines.ts verify() checked response.ok and threw the status-only message without reading the { error: { code, message } } body.

Change

  • The bridge answers a missing socket as HerdrError("socket_missing"): the usual envelope (404 through the existing mapping in server/http.ts), with no path in the message.
  • verify() reads the envelope and maps by code only; the bridge's own message is never shown, so no remote path or arbitrary upstream text reaches the dialog.
    • socket_missing, and the 500 internal_error + ENOENT that an already installed bridge still answers: "herdr is not running for this session on the PC (its socket is missing). Start herdr there, then reconnect."
    • connect_failed: "herdr is not answering on the PC (its socket is there, but nothing listens). Restart herdr there, then reconnect."
    • anything else (other codes, non-JSON bodies): the previous status-only message.
  • No new endpoint or frame; REMOTE_BUNDLE_VERSION is not bumped. The verify() half works against bridges already installed; the cleaner socket_missing answer reaches a remote PC with the next remote bundle.

Validation

Reproduction as in the issue: HERDR_SOCKET at a missing file in a temp dir, createServer on loopback (port 0, temp stateDir, machines:false, registerBridge:false, tailscaleOwner:null), GET /api/bridge, then the real MachineManager verify through a loopback relay standing in for the SSH forward; repeated with a plain file at the socket path.

Before (origin/main 2507b0c):

{"state":"missing socket/marker","status":500,"response":{"error":{"code":"internal_error","message":"ENOENT: no such file or directory, stat '<qa-temp>/herdr.sock'"}}}
{"state":"missing socket/marker","verificationMessage":"Bridge verification failed (500). Reconnect after checking the remote bridge."}
{"state":"marker exists but no daemon","status":502,"response":{"error":{"code":"connect_failed","message":"cannot reach herdr at <qa-temp>/herdr.sock: Failed to connect"}}}
{"state":"marker exists but no daemon","verificationMessage":"Bridge verification failed (502). Reconnect after checking the remote bridge."}

After:

{"state":"missing socket/marker","status":404,"response":{"error":{"code":"socket_missing","message":"herdr's socket is missing; herdr is not running for this session"}}}
{"state":"missing socket/marker","verificationMessage":"herdr is not running for this session on the PC (its socket is missing). Start herdr there, then reconnect."}
{"state":"marker exists but no daemon","status":502,"response":{"error":{"code":"connect_failed","message":"cannot reach herdr at <qa-temp>/herdr.sock: Failed to connect"}}}
{"state":"marker exists but no daemon","verificationMessage":"herdr is not answering on the PC (its socket is there, but nothing listens). Restart herdr there, then reconnect."}

New cases in server/machines.test.ts ("bridge verification failures"), same setup:

  • before the fix: 1 pass, 3 fail (Expected to contain: "herdr is not running" / Received: "Bridge verification failed (500). Reconnect after checking the remote bridge."; the passing one is the unchanged fallback)
  • after: 26 pass, 0 fail in HERDR_TEST_MODE=unit bun test ./server/machines.test.ts

Also green: bun run typecheck, bun run test:unit (1054 pass, 3 skip, 0 fail), bun test ./server/api.contract.test.ts (75 pass, 0 fail).

Fixes #352

…500/502

A bridge whose herdr socket is missing answers socket_missing instead of a 500 internal_error carrying the path, and verify() reads the error envelope: a missing socket (also from the 500 an installed older bridge answers) and connect_failed each get a message that names the cause. Any other answer keeps the status-only message.
@coderabbitai

coderabbitai Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

🧰 Additional context used
📚 Code guidelines (1)
CONTRIBUTING.md — configured

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: devswha/herdr-web-ui/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 1e389726-6c25-4d1d-92f3-ec914a0b2fd1

📥 Commits

Reviewing files that changed from the base of the PR and between 1e5691d and e466480.

📒 Files selected for processing (1)
  • CHANGELOG.md

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.


📝 Summary

Summary by CodeRabbit

  • Bug Fixes
    • Bridge verification now gives clearer feedback when Herdr is not running or not responding.
    • Error messages no longer expose socket paths.
    • Other verification failures include the response status and a general reconnect instruction. Older bridge responses indicating a missing socket are also recognized.

Walkthrough

Bridge verification now reports specific messages for missing Herdr sockets and unavailable listeners. Other failures retain a generic message with the HTTP status. Tests cover current and legacy bridge error responses.

Changes

Bridge verification errors

Layer / File(s) Summary
Report missing bridge sockets
server/bridge.ts
bridgeIdentity converts ENOENT from statSync into a HerdrError with code socket_missing. Other stat errors are rethrown.
Map bridge errors to verification messages
server/machines.ts, server/machines.test.ts, CHANGELOG.md
verify maps missing-socket and connection errors to specific messages. Other failures receive generic guidance with the HTTP status. Tests cover current and legacy errors and check that messages do not expose socket paths. The changelog records the updated messages.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: haeminway1

Merge Risk: ⚪ Minimal · up to e4664

Verification now distinguishes missing sockets from unavailable listeners while keeping other failures generic. No material merge risk is evident from the reviewed changes.

Architecture Summary

Architecture risk: 🔵 Low · up to e4664

The change affects 2 systems.

Changed systems: server, CHANGELOG.md

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — server (service) was modified; 3 changed files map to changed impact.
  • observed — CHANGELOG.md (service) was modified; 1 changed file maps to changed impact.

Before / after behavior

  • observed — Modified behavior in server/bridge.ts: The herdr client import now includes HerdrError.
  • observed — Modified behavior in server/bridge.ts: bridgeIdentity now catches errors from statSync: it converts ENOENT into a HerdrError with code socket_missing and a session-specific message, while rethrowing other errors. Previously, the stat call propagated all errors unchanged.
  • observed — Modified behavior in server/machines.test.ts: Added type and server imports used by the bridge verification tests.
  • observed — Modified behavior in server/machines.test.ts: Added bridge verification tests using real and fixed-response servers with an SSH-forward relay. They check that missing-socket errors from current and older bridges report herdr as not running without revealing paths, an unresponsive daemon is reported as not answering, and other 500, 503, or non-JSON responses produce a generic message containing only the status.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: reporting actionable reasons for bridge verification failures instead of only HTTP 500 or 502 statuses.
Description check ✅ Passed The description explains the problem, cause, implementation, security behavior, compatibility scope, and validation results. It covers the template's Change and Validation requirements despite using a…
Linked Issues check ✅ Passed The PR satisfies the coding requirements in [#352]. bridgeIdentity converts only ENOENT socket-stat failures to socket_missing and keeps other errors unchanged. verificationFailure maps `socke…
Out of Scope Changes check ✅ Passed The changes remain within [#352]. The PR changes bridge error classification, verification diagnostics, compatibility handling, focused tests, and the related changelog entry. It adds no remote reconn…
Docstring Coverage ✅ Passed Docstring coverage is 85.71% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 3 files. (1 skipped: 1 u…
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


Comment @coderabbitai help to get the list of available commands.

@devswha
devswha merged commit 3110a68 into main Oct 2, 2026
12 checks passed
@devswha
devswha deleted the fix/bridge-verify-errors branch October 2, 2026 19:38
devswha added a commit that referenced this pull request Oct 3, 2026
Bumps package.json and herdr-plugin.toml to 0.3.44, moves the Unreleased
notes under [0.3.44] - 2026-10-03, adds the compare link, and removes a
merge marker line left in CHANGELOG.md by #351's conflict resolution.
### Added
- Native Windows x64 installation through `install.ps1`, with the same
herdr plugin startup
and updates. Windows needs Bun and Git, without Node or WSL, and keeps
using the terminal
screen mirror. ([#330](#330)
by @JJLiebig)
- Settings can choose Chat, Terminal, or Auto as the default view for
panes. Changing it resets
remembered pane views on this device. Shell panes still open in
Terminal.
([#325](#325) by
@Haeminway1)
- Choose the terminal input line or direct typing on desktop as well as
touch screens, and
customize or unbind the app's Mod+Shift shortcuts with conflict checks
and reset.
  ([#334](#334))

### Changed
- In the sidebar's By workspace view, a workspace with one pane keeps
its numbered header and
can be folded, renamed and reordered from that header, just like a
workspace with several panes.
  ([#332](#332) by @beomq)
- The top usage panel shows larger percentages, remaining-capacity
colors and compact reset
countdowns with their local time. Expired reset times stay hidden until
fresh usage arrives.
([#336](#336) by
@Haeminway1)
- Pane titles that contain a directory show its last folder, and
matching workspace and folder
names appear once in the sidebar and command palette, including Windows
paths.
([#337](#337) by
@Haeminway1)
- In the sidebar's By workspace view, a pane row no longer repeats the
workspace its header names.
Its second line shows the folder only when neither the title nor the
workspace already says it.
  ([#358](#358))

### Fixed
- GJC conversations are resolved from the foreground process directory
when it differs from
the pane directory.
([#333](#333) by @Kinetic27)
- Direct terminal input preserves rapid IME commits when punctuation
arrives before composition
timers run, with a bounded xterm 5.5 backport and Korean final-consonant
regression checks.
Native Android/Gboard checks also fixed stale editor text after
Backspace breaking the next
Hangul word. Secret entry now refuses a held or unready attachment and
failed PTY writes.
  ([#334](#334))
- New session in the browser demo opens the new session instead of
leaving a blank page.
  ([#355](#355))
- Terminal input keeps multi-character IME commits and emoji while
disconnected, waits for the
attachment before sending keys, and reports input failures. Unsent input
lines survive pane,
lens and mode changes; late acknowledgements preserve replacement edits.
Composition keeps
its Enter and Send button, and terminal key-bar taps wait until it
finishes.
  ([#334](#334))
- The background tasks list stays below the app header on a short
screen, such as a phone held
  sideways, and scrolls inside the room above the message box.
  ([#354](#354))
- The mobile message box sits closer to the home indicator while
retaining its base spacing.
([#335](#335) by
@Haeminway1)
- Adding or reconnecting a remote PC says when herdr is not running or
not answering there,
  instead of only `Bridge verification failed (500)`.
  ([#353](#353))
- Shift+Enter in the live terminal sends the same newline chord as
Alt+Enter, instead of plain
Enter that submits an agent's message. Pending IME text is sent before
the newline chord.
([#339](#339) by
@WOULDU-pres)
- On Windows, and from an install path with a space or a non-ASCII
character, the app page loads
instead of the "not built yet" notice. The Windows installer replaces a
copy from a release
  without Windows support, and says so when a release cannot run there.
  ([#356](#356))
- On an iPhone home screen app, a text field that keeps its focus with
the keyboard down no
  longer leaves a status-bar band under the message box.
([#349](#349) by
@Haeminway1)
- After `/new` in an OmO pane, the chat stops showing the conversation
before it: OmO writes the
new session's file only with its first message, and until then the chat
shows what a fresh OmO
shows. ([#351](#351) by
@WOULDU-pres)
- On a Windows PC, an omo pane shows omo's mark instead of Claude's, and
its chat finds the
conversation: process words with `bun.exe`, backslashes and a drive
letter read as omo, and the
  session folder is named as omo's engine names a Windows folder.
([#342](#342) by
@Haeminway1)
- The chat lens finds an omo pane's conversation when its process keeps
its sessions outside
`~/.omo/agent` (`OMO_CODING_AGENT_DIR`, `SENPI_CODING_AGENT_DIR` or
`PI_CODING_AGENT_DIR`).
([#350](#350) by
@Haeminway1) passes. After the merge: .
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.

Remote bridge verification discards actionable errors and reports only HTTP 500/502

1 participant