myxce/.wolf/bugs/bug-1961.md
Rongsong Shen f45b85c9e5
docs(buglog): record Gitea sync for bug-1958..bug-1967
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-10 10:51:33 +00:00

2.9 KiB

id status status_updated status_note component severity timestamp last_seen occurrences files tags related fix_commits gitea_issue gitea_synced_status gitea_synced_hash
bug-1961 fixed 2026-10-10 apiserver wrong-result 2026-10-10T10:16:04Z 2026-10-10T10:16:04Z 1
src/frontend/apiserver/controllers/hosts.go
apiserver
hosts
d720132c
392 fixed da9667fb5610

bug-1961: apiserver ControlHost writes a second response after validateHost rejected the request

Description

Observed: (source reading; follow-up of the 2026-10-10 P0 fixes (bug-1936..1957)) Reported by the bug-1949 fix: validateHost (controllers/hosts.go) writes a 403 via ReturnError without aborting and ControlHost continues and writes another response (today masked by the route's RequirePermission).

Expected: A rejected host control stops after the first error response. Impact: Wrong result / noise: double responses, possible action after a rejection if the route guard changes. Found by: follow-up of the 2026-10-10 P0 fixes (bug-1936..1957)

Environment

  • OS: no /etc/os-release; Docker container; NixOS kernel; kernel Linux 6.18.33 x86_64
  • libc: glibc 2.42-47 (interpreter /nix/store/wb6rhpznjfczwlwx23zmdrrw74bayxw4-glibc-2.42-47/lib/ld-linux-x86-64.so.2)
  • Toolchain: gcc (GCC) 15.2.0, meson 1.9.1
  • Build: asan (xce.build)
  • Code: scheduler-framework @ 19be145d-dirty
  • Deployment: any (found by source reading; confirmed by the RED test of the fix)

Reproduction

  1. Call ControlHost so that validateHost rejects (see the handler) with the route guard removed in a unit test; two writes occur.
  • Frequency: deterministic (by code reading; confirmed by the RED test of the fix)
  • Evidence: the code sites quoted in Description; no logs kept.

Root cause

validateHost (controllers/hosts.go) wrote a 403 via ReturnError without aborting, so ControlHost's IsAborted() check never fired and it wrote a second (202) response. Pre-existing.

Fix

validateHost no longer writes a response: it checks host:control once, before the host loop (it used to check per host and not at all for an empty list), and returns an error; ControlHost writes a single 403 and returns; for all the host list is resolved first.

Verification

  • Test: TestControlHost_RejectedWritesSingleResponse (controllers/hosts_handler_test.go, route without its guard): RED hosts_handler_test.go:61: handler wrote 2 responses, want 1, GREEN after.
  • Suites: xce-build.sh all asan xce.build --incremental on the merged branch, 2026-10-10: C suites Ok 157 / Fail 0; frontend Go tests ok (the build now also runs apiserver cmd, middleware, models and router)
  • Live: n/a: unit/fixture-level verification; no live deployment was run

References

  • Fix commits: d720132c (on scheduler-framework)
  • Found as a follow-up of the 2026-10-10 P0 fixes (bug-1936..1957)