Skip to content

UDP health check panics when the tracker answers with an invalid response #2867

Closed

Description

@josecelano-bot

Summary

When a UDP tracker answers the health check with a datagram that is not a valid tracker response, GET /health_check panics instead of reporting an error for that service. The HTTP connection is dropped and the client gets no report at all, not even for the other services.

Found on 2026-11-15 during the red-then-green check of #2393 (EPIC #2392). It is out of scope there, because that implementation only touches tests.

What happens

  1. torrust_tracker_client::udp::client::check (packages/tracker-client/src/udp/client.rs) sends a connect request and races client.receive() against a 2 s sleep.
  2. The reply does not parse, so receive() correctly returns Err(Error::UnableToParseResponse { .. }).
  3. check calls process(response.unwrap()) and the check task panics.
  4. In packages/axum-health-check-api-server/src/handlers.rs, the per-service task panics on .expect("it should be able to join into the checking function"), and the handler panics on .expect("it should be able to connect to the job").
  5. The router has no panic-catching layer, so the connection is dropped (hyper::Error(IncompleteMessage) on the client side).

check already returns Err("Timed Out") and Err("Did not Connect") for the other failure modes, and the endpoint reports other failed services as status Error with an Err(..) detail. A closed UDP port does not panic: it reports Timed Out.

Reproduction

Reproduced on develop at abd7a10ff with a temporary integration test that registers a UDP socket answering every datagram with the bytes junk, checked by the production Launcher::check. The test code, commands and output are in the issue spec's manual-verification-evidence.md and evidence/ folder (spec-only PR to follow).

Proposed fix

  • check returns Err(..) naming the cause when receive() fails, instead of panicking; fix its stale # Panics doc comment.
  • The health-check handler reports a check job that panicked or was cancelled (JoinError) as a failed check for that service, and the outer join does not panic. The report then has status Error with the other services' results intact.
  • Regression tests, each proven red first: a tracker-client unit test with a junk-answering socket, and a health-check contract test with a probe whose job panics.

Spec-first: the specification goes in a spec-only PR before any code.

Activity

  1. added 9 commits that reference this issue on Nov 15, 2026
  2. added 2 commits that reference this issue on Nov 16, 2026
  3. added 4 commits that reference this issue on Nov 16, 2026
  4. 14 remaining items

  5. added a commit that references this issue on Nov 16, 2026
  6. added a commit that references this issue on Nov 16, 2026
  7. added a commit that references this issue on Nov 16, 2026
  8. added 7 commits that reference this issue on Nov 16, 2026
  9. added a commit that references this issue on Nov 16, 2026
  10. added 2 commits that reference this issue on Nov 16, 2026
  11. added a commit that references this issue on Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions