Skip to content

Improve doctor reachability diagnostics#35

Open
bowersjames wants to merge 1 commit into
Waishnav:mainfrom
bowersjames:codex/doctor-reachability
Open

Improve doctor reachability diagnostics#35
bowersjames wants to merge 1 commit into
Waishnav:mainfrom
bowersjames:codex/doctor-reachability

Conversation

@bowersjames

@bowersjames bowersjames commented Jun 24, 2026

Copy link
Copy Markdown

Summary

  • add endpoint health helpers for local/public reachability checks
  • teach doctor to report local server and public tunnel health separately
  • include actionable guidance when DevSpace or its tunnel is unreachable

Verification

  • node node_modules/tsx/dist/cli.mjs src/config.test.ts src/roots.test.ts src/skills.test.ts src/workspaces.test.ts src/review-checkpoints.test.ts src/oauth-store.test.ts src/health.test.ts src/cli.test.ts
  • node node_modules/typescript/bin/tsc -p tsconfig.json --noEmit
  • node node_modules/vite/bin/vite.js build
  • node node_modules/typescript/bin/tsc -p tsconfig.build.json

Summary by CodeRabbit

  • New Features

    • The doctor command now checks both local and public health endpoints and reports whether each one is reachable.
    • Output now includes clearer health status messages and tailored next-step guidance when an endpoint is unhealthy.
  • Tests

    • Added coverage for successful, failed, and error-prone health checks to improve reliability.

@coderabbitai

coderabbitai Bot commented Jun 24, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

A new src/health.ts module is added exposing EndpointHealth, checkEndpoint (fetch with 5s timeout, structured error mapping), and formatEndpointHealth. These are imported into src/cli.ts and wired into runDoctor() to probe /healthz on the local server and public tunnel, printing conditional action guidance. Tests and the test script are updated accordingly.

Changes

Health-check module and devspace doctor integration

Layer / File(s) Summary
EndpointHealth contract, checkEndpoint, formatEndpointHealth, and tests
src/health.ts, src/health.test.ts
Defines EndpointHealth interface (ok, optional status, optional error), implements checkEndpoint with a 5s AbortSignal.timeout and structured OK/non-OK/exception mapping, adds formatEndpointHealth for human-readable reachability strings, and validates all three response cases with assert.deepEqual async tests.
devspace doctor health probe and action guidance
src/cli.ts, package.json
Imports checkEndpoint and formatEndpointHealth in cli.ts; updates runDoctor() to derive /healthz URLs, run both health checks, format results, and print conditional Action: lines when local or public health is not OK. Updates the package.json test script to include src/health.test.ts.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐇 Hop hop, the doctor is in!
With a /healthz ping and a tunnel grin,
If your server's down, I'll say "start serve",
If the tunnel's lost, I'll preserve your nerve.
Structured errors, timeouts just right —
The warren stays healthy, morning to night! 🌟

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change: richer doctor reachability diagnostics for local and public endpoints.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/cli.ts`:
- Around line 225-226: Normalize the host used for the local probe URLs in the
CLI so `localMcpUrl` and `localHealthUrl` are built from a loopback-safe address
instead of raw `config.host`, since IPv6 literals and bind-all hosts can produce
invalid or unusable URLs. Update the URL construction in the `src/cli.ts` logic
that builds the local probe endpoints to match the same host-normalization
behavior used by `localPublicBaseUrl()`, including bracketed IPv6 handling and
replacing `0.0.0.0`/`::` with a loopback address.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 250eec39-1e02-4daa-b6bb-386063f89724

📥 Commits

Reviewing files that changed from the base of the PR and between 65be252 and f028294.

📒 Files selected for processing (4)
  • package.json
  • src/cli.ts
  • src/health.test.ts
  • src/health.ts

Comment thread src/cli.ts
Comment on lines +225 to +226
const localHealthUrl = `http://${config.host}:${config.port}/healthz`;
const publicHealthUrl = new URL("/healthz", config.publicBaseUrl).toString();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
rg -nP '\bhost\b' src/config.ts -C2
rg -nP 'DEVSPACE_HOST|host\s*[:=]' src/config.ts -C2

Repository: Waishnav/devspace

Length of output: 2133


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect the relevant config and CLI code around the reported lines.
sed -n '200,270p' src/config.ts
printf '\n--- CLI ---\n'
sed -n '210,255p' src/cli.ts

Repository: Waishnav/devspace

Length of output: 4458


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect the relevant config and CLI code around the reported lines.
sed -n '200,270p' src/config.ts
printf '\n--- CLI ---\n'
sed -n '210,255p' src/cli.ts

Repository: Waishnav/devspace

Length of output: 4458


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Check how config.host is parsed from files and whether any validation constrains it.
rg -n "files\.config\.host|host:" src/config.ts -C3
printf '\n--- loadDevspaceFiles ---\n'
sed -n '1,220p' src/config.ts

Repository: Waishnav/devspace

Length of output: 8335


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Check how config.host is parsed from files and whether any validation constrains it.
rg -n "files\.config\.host|host:" src/config.ts -C3
printf '\n--- loadDevspaceFiles ---\n'
sed -n '1,220p' src/config.ts

Repository: Waishnav/devspace

Length of output: 8335


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect how the endpoint checker consumes the constructed URLs.
rg -n "function checkEndpoint|checkEndpoint\(" src/cli.ts -C3
sed -n '1,120p' src/cli.ts

Repository: Waishnav/devspace

Length of output: 4600


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect how the endpoint checker consumes the constructed URLs.
rg -n "function checkEndpoint|checkEndpoint\(" src/cli.ts -C3
sed -n '1,120p' src/cli.ts

Repository: Waishnav/devspace

Length of output: 4600


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect how the endpoint checker consumes the constructed URLs.
rg -n "function checkEndpoint|checkEndpoint\(" src/cli.ts -C3
sed -n '1,120p' src/cli.ts

Repository: Waishnav/devspace

Length of output: 4600


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect the health checker to see how these URLs are consumed.
sed -n '1,220p' src/health.ts

Repository: Waishnav/devspace

Length of output: 1047


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect the health checker to see how these URLs are consumed.
sed -n '1,220p' src/health.ts

Repository: Waishnav/devspace

Length of output: 1047


Normalize the probe host before building local URLs.
HOST/files.config.host is unrestricted (default 127.0.0.1), so localMcpUrl and localHealthUrl can break for IPv6 literals like ::1 and can point at unusable bind-all addresses like 0.0.0.0/::. Use a loopback address for probes and bracket IPv6 hosts, matching localPublicBaseUrl().

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/cli.ts` around lines 225 - 226, Normalize the host used for the local
probe URLs in the CLI so `localMcpUrl` and `localHealthUrl` are built from a
loopback-safe address instead of raw `config.host`, since IPv6 literals and
bind-all hosts can produce invalid or unusable URLs. Update the URL construction
in the `src/cli.ts` logic that builds the local probe endpoints to match the
same host-normalization behavior used by `localPublicBaseUrl()`, including
bracketed IPv6 handling and replacing `0.0.0.0`/`::` with a loopback address.

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