Skip to content

fix(api): avoid double response on GET /api/cluster when HA is off#3887

Draft
cursor[bot] wants to merge 1 commit into
developfrom
cursor/critical-correctness-bugs-49cb
Draft

fix(api): avoid double response on GET /api/cluster when HA is off#3887
cursor[bot] wants to merge 1 commit into
developfrom
cursor/critical-correctness-bugs-49cb

Conversation

@cursor

@cursor cursor Bot commented May 25, 2026

Copy link
Copy Markdown

Bug and impact

getClusterStatus attempted to send two HTTP responses when high availability was disabled: first 200 with {"ha_enabled": false}, then 503 because the cluster inspector is absent in that configuration. That violates net/http response semantics and produced broken or inconsistent responses for non-HA installs hitting GET /api/cluster (for example from the cluster dashboard or admin tooling).

Root cause

Commit da6c357c added an early WriteJSON for the non-HA case but omitted return, and placed node_id after that block so the handler always continued into the nil-inspector error path.

Fix and validation

  • Return immediately after writing the minimal JSON payload when !util.HAEnabled(), and populate node_id before that branch when util.Config.HA is set.
  • Updated TestGetClusterStatus_HADisabled to expect 200, ha_enabled: false, and no nodes/redis keys.

Tests: mkdir -p api/public && touch api/public/.keep && go test ./api/... (the api/public placeholder satisfies the go:embed pattern in this checkout).

Open in Web View Automation 

getClusterStatus wrote a 200 response for non-HA deployments but fell
through to the nil-inspector branch, causing a second write (503) and
invalid responses for GET /api/cluster. Return immediately after the
minimal payload and align the unit test with the documented behavior.

Co-authored-by: Denis Gukov <fiftin@outlook.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