|
| 1 | +--- |
| 2 | +doc-type: issue |
| 3 | +issue-type: task |
| 4 | +status: planned |
| 5 | +priority: p3 |
| 6 | +github-issue: 1447 |
| 7 | +spec-path: docs/issues/open/1447-change-logging-threshold-connection-id-error.md |
| 8 | +branch: "1447-change-logging-threshold-connection-id-error" |
| 9 | +related-pr: null |
| 10 | +last-updated-utc: 2026-07-13 12:00 |
| 11 | +semantic-links: |
| 12 | + skill-links: |
| 13 | + - create-issue |
| 14 | + related-artifacts: |
| 15 | + - packages/udp-server/src/handlers/error.rs |
| 16 | +--- |
| 17 | + |
| 18 | +# Issue #1447 - Change the logging threshold for connection ID error to `WARNING` |
| 19 | + |
| 20 | +## Goal |
| 21 | + |
| 22 | +Change the log level for UDP connection ID errors from `ERROR` to `WARNING` to reduce |
| 23 | +log noise in production deployments (especially the Torrust Tracker demo). |
| 24 | + |
| 25 | +## Background |
| 26 | + |
| 27 | +The UDP tracker receives a high volume of requests with invalid connection IDs from |
| 28 | +misconfigured or abusive peers. These produce errors like: |
| 29 | + |
| 30 | +- `cookie value is expired` |
| 31 | +- `cookie value is from future` |
| 32 | + |
| 33 | +These are currently logged at `ERROR` level, which floods the logs and makes it hard to |
| 34 | +identify other types of errors. |
| 35 | + |
| 36 | +The tracker already bans IPs that make too many such requests (tracked via the |
| 37 | +`udp_tracker_server_connection_id_errors_total` metric and the ban service), so the |
| 38 | +logging can safely be downgraded. A `WARNING` level is still appropriate because there |
| 39 | +is no other monitoring/analytics tool to detect unusual patterns — the log remains the |
| 40 | +primary observability channel for connection ID issues. |
| 41 | + |
| 42 | +This is not an application error — it is expected behaviour from bad client traffic. |
| 43 | + |
| 44 | +## Scope |
| 45 | + |
| 46 | +### In Scope |
| 47 | + |
| 48 | +- Change the `tracing::error!` call in `log_error()` in `packages/udp-server/src/handlers/error.rs` to `tracing::warn!` |
| 49 | +- Verify that the change does not break any tests that assert on log level or output |
| 50 | +- Run `linter all` and the full test suite |
| 51 | + |
| 52 | +### Out of Scope |
| 53 | + |
| 54 | +- Adding a configuration option for the log level (not configurable for now) |
| 55 | +- Changing log levels for other error types |
| 56 | +- Changing the banning behaviour (stays at `ERROR`-level events) |
| 57 | +- Adding separate monitoring/analytics tooling |
| 58 | + |
| 59 | +## Implementation Plan |
| 60 | + |
| 61 | +Status values: `TODO`, `IN_PROGRESS`, `BLOCKED`, `DONE`. |
| 62 | + |
| 63 | +| ID | Status | Task | Notes / Expected Output | |
| 64 | +| --- | ------ | --------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- | |
| 65 | +| T1 | TODO | Change log level in `handlers/error.rs` | Make `log_error()` inspect the error type: use `tracing::warn!` for `ConnectionCookie` errors, keep `tracing::error!` for all other error types | |
| 66 | +| T2 | TODO | Run verification | `linter all`, `cargo test --workspace`, pre-commit checks | |
| 67 | + |
| 68 | +## Technical Details |
| 69 | + |
| 70 | +The `ServerError` type in `packages/udp-server/src/error.rs` has several variants. |
| 71 | +Connection cookie errors flow through two paths: |
| 72 | + |
| 73 | +- `Error::AnnounceFailed { source: UdpAnnounceError::ConnectionCookieError { .. } }` |
| 74 | +- `Error::ScrapeFailed { source: UdpScrapeError::ConnectionCookieError { .. } }` |
| 75 | + |
| 76 | +The current `log_error()` function in `packages/udp-server/src/handlers/error.rs` is called for **all** UDP error types, not just connection cookie errors: |
| 77 | + |
| 78 | +```rust |
| 79 | +fn log_error( |
| 80 | + error: &Error, |
| 81 | + client_socket_addr: SocketAddr, |
| 82 | + server_socket_addr: SocketAddr, |
| 83 | + opt_transaction_id: Option<TransactionId>, |
| 84 | + request_id: Uuid, |
| 85 | +) { |
| 86 | + match opt_transaction_id { |
| 87 | + Some(transaction_id) => { |
| 88 | + let transaction_id = transaction_id.0.to_string(); |
| 89 | + tracing::error!(target: UDP_TRACKER_LOG_TARGET, error = %error, %client_socket_addr, %server_socket_addr, %request_id, %transaction_id, "response error"); |
| 90 | + } |
| 91 | + None => { |
| 92 | + tracing::error!(target: UDP_TRACKER_LOG_TARGET, error = %error, %client_socket_addr, %server_socket_addr, %request_id, "response error"); |
| 93 | + } |
| 94 | + } |
| 95 | +} |
| 96 | +``` |
| 97 | + |
| 98 | +The implementation should inspect the error variant and use `tracing::warn!` for |
| 99 | +`ConnectionCookie` errors while keeping `tracing::error!` for other error types |
| 100 | +(invalid requests, announce/scrape errors, internal errors, etc.). |
| 101 | + |
| 102 | +The `Error` type derives `Clone` and can be pattern-matched. Matching on |
| 103 | +`matches!(error, Error::AnnounceFailed { source: UdpAnnounceError::ConnectionCookieError { .. } })` |
| 104 | +or similar approach. |
| 105 | + |
| 106 | +Note: The `ErrorKind::ConnectionCookie` variant is specifically handled by the banning |
| 107 | +event handler (`packages/udp-server/src/banning/event/handler.rs`) to track IP bans |
| 108 | +separately — this behaviour is unaffected by the log level change. |
| 109 | + |
| 110 | +## Progress Tracking |
| 111 | + |
| 112 | +### Workflow Checkpoints |
| 113 | + |
| 114 | +- [x] Spec drafted in `docs/issues/open/` |
| 115 | +- [ ] Spec reviewed and approved by user/maintainer |
| 116 | +- [ ] GitHub issue exists and issue number matches spec |
| 117 | +- [ ] Implementation completed |
| 118 | +- [ ] Automatic verification completed (`linter all`, relevant tests, and any pre-push checks) |
| 119 | +- [ ] Manual verification scenarios executed and recorded (status + evidence) |
| 120 | +- [ ] Acceptance criteria reviewed after implementation and updated with evidence |
| 121 | +- [ ] Reviewer validated acceptance criteria and updated checkboxes |
0 commit comments