Skip to content

Fix: OpenClaw health check falsely reports connected when endpoint returns 404#50

Open
kbaker827 wants to merge 2 commits intoIntent-Lab:mainfrom
kbaker827:fix/openclaw-health-check-status-range
Open

Fix: OpenClaw health check falsely reports connected when endpoint returns 404#50
kbaker827 wants to merge 2 commits intoIntent-Lab:mainfrom
kbaker827:fix/openclaw-health-check-status-range

Conversation

@kbaker827
Copy link
Copy Markdown

@kbaker827 kbaker827 commented Apr 16, 2026

Problem

When the /v1/chat/completions endpoint is disabled in openclaw.json, the gateway returns 404. The health check in checkConnection() was accepting HTTP 200–499 as "connected", so a 404 silently showed a green indicator while every tool call failed.

Fixes #36

Solution

Exclude 404 specifically from the accepted status range, keeping the rest of 200–499 intact.

The original 200–499 range was intentional: a GET request to /v1/chat/completions on a healthy gateway may return a 4xx (e.g. 400 Bad Request or 405 Method Not Allowed) because the endpoint only accepts POST with a JSON body. Narrowing to 200–299 would cause a correctly-configured gateway to falsely show as "unreachable".

// Before (treats disabled 404 as connected)
(200...499).contains(http.statusCode)

// After (only 404 = endpoint disabled = unreachable)
(200...499).contains(http.statusCode), http.statusCode != 404

Test plan

  • Start OpenClaw without chatCompletions.enabled: true in openclaw.json
  • Open the app — confirm the connection indicator shows red/unreachable (was incorrectly green before)
  • Enable chatCompletions in openclaw.json and restart the gateway
  • Confirm the indicator goes green (gateway returns a non-404 4xx or 2xx)
  • Confirm tool calls work end-to-end

🤖 Generated with Claude Code

kbaker827 and others added 2 commits April 16, 2026 11:51
checkConnection() accepted HTTP 200-499 as "connected", so a 404 from
a disabled /v1/chat/completions endpoint would show a green indicator
while all tool calls silently fail.

Narrow to 200-299 only so users get an accurate unreachable state when
the chatCompletions endpoint is not enabled in openclaw.json.

Fixes Intent-Lab#36

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
A GET to /v1/chat/completions on a healthy OpenClaw gateway may return
a 4xx (e.g. 400 Bad Request or 405 Method Not Allowed) because the
endpoint only accepts POST with a JSON body. The original 200-499 range
was intentional for exactly this reason.

Narrowing to 200-299 would cause a correctly-configured gateway to show
as "unreachable". Instead, exclude only 404 — the status that indicates
the chatCompletions endpoint is explicitly disabled in openclaw.json.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

Bug: /v1/chat/completions endpoint disabled by default — tool calls silently fail

1 participant