Skip to content

fix: self-check gateway probe misreports connection-refused as pass#29

Merged
gitricko merged 2 commits into
mainfrom
fix/self-check-gateway-bug
Jun 23, 2026
Merged

fix: self-check gateway probe misreports connection-refused as pass#29
gitricko merged 2 commits into
mainfrom
fix/self-check-gateway-bug

Conversation

@gitricko

Copy link
Copy Markdown
Owner

Summary

One-line fix to docker/self-check.sh — the Hermes gateway health check was incorrectly reporting ✅ Gateway HTTP 000000 when the dashboard/gateway port (9119) was unreachable, because of a bash stdout-concatenation bug in the curl fallback pattern.

The Bug

# Before (broken):
has_gateway=$(curl ... || echo "000")

When curl to an unreachable port returns 000 (from -w %{http_code}) AND the || echo "000" fallback fires, stdout gets concatenated: 000 + 000 = 000000 (6 chars).

The downstream check:

[ "$has_gateway" != "000" ]

Then evaluates "000000" != "000" as true (bash string comparison), so the gateway is reported as even though it is actually down.

The Fix

# After (fixed):
has_gateway=$(curl ... || true)
has_gateway="${has_gateway:-000}"
  • || true prevents the non-zero exit from killing the set -e script, but adds nothing to stdout
  • "${has_gateway:-000}" only substitutes 000 when the result is truly empty
  • No concatenation → 000 stays 000[ "000" != "000" ] is false → gateway correctly reported as

How to Test Locally

  1. Ensure dashboard/gateway on port 9119 is not running
  2. Run the script: HERMES_GATEWAY_URL=http://localhost:9119 ./docker/self-check.sh
  3. Before fix: Shows ✅ Gateway HTTP 000000 at http://localhost:9119
  4. After fix: Shows ❌ Gateway no response from http://localhost:9119

Checklist

  • One surgical change — just the fallback pattern
  • No other behaviour affected
  • Service port polling (line 196) uses a different pattern and is unaffected

gitricko and others added 2 commits June 23, 2026 07:10
… as pass

The gateway probe uses 000 to default the HTTP
code on failure. When curl returns  (connection refused) AND the
 fallback fires, stdout gets concatenated as  (6 chars).
Bash string comparison  then evaluates as
true, causing the gateway to be reported as ✅ up when it is actually
down.

Fix: replace  with  + bash parameter expansion
. This avoids stdout concatenation entirely —
curl's  output stays clean, and only empty results get the 000
default.
@gitricko gitricko merged commit 6c0ce90 into main Jun 23, 2026
4 checks passed
@gitricko gitricko deleted the fix/self-check-gateway-bug branch June 23, 2026 12:05
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