Skip to content

fix: proper OpenClaw health check + scopes header (fixes #36)#39

Open
juliosuas wants to merge 1 commit intoIntent-Lab:mainfrom
juliosuas:fix/openclaw-health-check
Open

fix: proper OpenClaw health check + scopes header (fixes #36)#39
juliosuas wants to merge 1 commit intoIntent-Lab:mainfrom
juliosuas:fix/openclaw-health-check

Conversation

@juliosuas
Copy link
Copy Markdown

Problem

checkConnection() on both iOS and Android treated any HTTP status 200-499 as "connected". This meant:

  • 404 (endpoint disabled by default) → falsely showed gateway as connected
  • 403 (missing scopes / bad token) → falsely showed gateway as connected
  • Tool calls then failed silently with no user-visible error

This is the root cause of Issue #36 — first-time users see "Connected" but every tool call returns 404 or 403.

Fix

Two-step health check

  1. /health — verifies the gateway process is running
  2. /v1/chat/completions (GET) — verifies the endpoint is enabled and auth works

Specific error messages

HTTP Status Before After
404 ✅ "Connected" ❌ "chatCompletions endpoint disabled — enable it in openclaw.json"
401/403 ✅ "Connected" ❌ "Authentication failed — check your gateway token"
Network error ❌ Generic error ❌ "Gateway unreachable: {details}"
200/405 ✅ "Connected" ✅ "Connected"

x-openclaw-scopes header

Added x-openclaw-scopes: operator.write to delegateTask() on both iOS and Android. Required by OpenClaw 2026.3.x+ — without it, all POST requests fail with HTTP 403 missing scope: operator.write.

Files Changed

  • samples/CameraAccess/CameraAccess/OpenClaw/OpenClawBridge.swift (iOS)
  • samples/CameraAccessAndroid/.../openclaw/OpenClawBridge.kt (Android)

Test plan

  • iOS: Configure OpenClaw with valid token → shows "Connected"
  • iOS: Disable chatCompletions endpoint → shows specific "endpoint disabled" error
  • iOS: Use wrong token → shows "Authentication failed" error
  • iOS: Stop gateway → shows "Gateway unreachable" error
  • Android: Same 4 scenarios verified
  • Tool calls succeed on both platforms with scopes header

🤖 Generated with Claude Code

The previous checkConnection() treated HTTP 200-499 as "connected",
which meant a 404 (endpoint disabled) or 403 (auth failed) would
falsely show the gateway as connected. Tool calls then failed silently.

Changes:
- Two-step health check: /health first, then /v1/chat/completions
- Specific error messages for 401/403 (bad token), 404 (endpoint
  disabled), and unreachable (gateway not running)
- Add x-openclaw-scopes: operator.write header to delegateTask()
  on both iOS and Android (required by OpenClaw 2026.3.x+)

Co-Authored-By: Claude Opus 4.6 (1M context) <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.

1 participant