Skip to content

Show the server's host package error in the machine installer - #4212

Merged
ymichael merged 2 commits into
mainfrom
bb/diagnose-error-from-user-logs-thr_3s8umdj4uf
Sep 23, 2026
Merged

ymichael merged 2 commits into
mainfrom
bb/diagnose-error-from-user-logs-thr_3s8umdj4uf

Conversation

@ymichael

@ymichael ymichael commented Sep 23, 2026 •

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

When GET /install/bb-app.tgz couldn't build or read the host package, the exception fell through to the global error handler. That handler returns {"code":"internal_error","message":"Internal server error"}, and the installer ignored the body, so users only saw Could not download the server's bb-app package … (HTTP 500). Nothing tied that failure to an entry in the server log. #3773 (spawn npm ENOENT) and #3118 (missing README.md) both reached users as this bare 500.

What changed

  • apps/server/src/server.ts: the route catches failures and logs the full error as "Host package download failed" with a new diagnosticId. It returns 500 with { code: "host_package_unavailable", message, diagnosticId } and cache-control: no-store. The message is a generic reason picked from the error code (missing file, permissions, disk full, or other), plus the diagnostic ID.
  • Raw exception text is deliberately left out of the response. The install routes are public, including on a Connect server's main handle (apps/connect/src/worker.ts, isPublicInstallPath), and raw messages can contain absolute server paths (and so the OS username). Showing detailed errors only to callers that present an enroll key or daemon host key is a possible follow-up.
  • apps/server/src/assets/install-machine.sh: on any 4xx/5xx the installer reads the body as JSON and prints Server: <message> before its existing fallback or failure step. It skips bodies over 16 KB, replaces control characters and caps the message at 2000 characters. Non-JSON bodies such as proxy HTML pages print nothing extra.
  • docs/configuration.md: documents the behaviour.

This isn't a daemon wire change. The route and the installer ship together from the same server.

Example installer output:

  ○  Downloading the server's bb-app package (timeout: 5 minutes)
     Server: The server ran out of disk space while preparing the host package. Check the server logs for diagnostic ID 3f9c2a1e-…, then retry installation.
  ✗  Could not download the server's bb-app package from https://…/install/bb-app.tgz (HTTP 500).

How you verified

  • skeleton.test.ts: for each error-code group, the route returns 500 with no-store, the expected generic reason and a diagnostic ID, and doesn't include the raw error text. The logged diagnosticId matches the one in the response.
  • install-machine-script.test.ts: when the fixture returns a 500, the installer prints Server: … for a JSON body, prints nothing extra for HTML or invalid JSON, and never runs npm install.
  • pnpm exec turbo run typecheck lint test --filter=@bb/server passes.
  • Manual: I started a pnpm start:worktree server with <dataDir>/install-cache replaced by a plain file and confirmed that /install/bb-app.tgz returned 500 with the new JSON body and that the error was logged as "Host package download failed".

AGENT GENERATED

🤖 Generated with Claude Code

ymichael and others added 2 commits September 23, 2026 13:11
When /install/bb-app.tgz failed to build or read the host package, the
route fell through to the global error handler and the installer only
printed "HTTP 500". The route now logs the failure and returns the
underlying error message, and the installer prints it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The install routes are public, including on a Connect server's main
handle, so raw exception text could expose server paths. Map the error
to a generic reason and return a diagnostic ID that matches the server
log entry instead.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@ymichael
ymichael merged commit 36fdd7f into main Sep 23, 2026
40 of 42 checks passed
@ymichael
ymichael deleted the bb/diagnose-error-from-user-logs-thr_3s8umdj4uf branch September 23, 2026 22:14
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