Repository navigation
fix(http-protocol): [#2915] remove source locations from HTTP tracker request errors - #2968
Conversation
…ailure reasons name no source path Unit tests at the parse and conversion seams of `http-protocol` and the `axum-http-server` extractors, and one HTTP-server test per failure family, assert that the text of each request-parsing, key-extraction and peer-IP-resolution error holds no source path and names what failed. They fail against the current code, which prints a `Location::caller()` and, for the short info-hash and peer-id cases, a `LocatedError` source. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…tracker request errors Remove the `location` field and its `Location::caller()` capture from the 10 variants of `ParseQueryError`, `ParseAnnounceQueryError`, `ParseScrapeQueryError`, `PeerIpResolutionError` and `auth::Error`, and from the `axum-http-server` extractors that build them. The `failure reason` an HTTP tracker sends no longer holds a source path. The six messages that had no input lose their only context with the location, so they are reworded to say what failed: a missing URL query, the missing `X-Forwarded-For` IP behind a reverse proxy, a missing connection socket address, and an authentication key that is malformed or absent from the URL path. The key is a secret, so its message names the expected format instead of the key. The three `LocatedError` sources are replaced in the next commit. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…fo-hash and peer-id param errors
`ParseAnnounceQueryError::{InvalidInfoHashParam, InvalidPeerIdParam}` and
`ParseScrapeQueryError::InvalidInfoHashParam` kept their source in a
`LocatedError`, which prints its own location, and the info-hash source,
`torrust_info_hash::ConversionError`, prints a registry path of its own.
Keep each source as a plain `#[source]` field and do not format it into
the message, which reaches the client: the message names the param, its
value and the expected 20-byte length.
`torrust-tracker-http-protocol` no longer depends on `torrust-located-error`.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…uns and the wording table Add `manual-verification-evidence.md` with the before and after responses of eleven malformed requests against a public, a reverse-proxy and a private tracker, the red and green test runs, and the table of old and new failure-reason texts for the wording review. Update the spec's task table, checkpoints, acceptance criteria and progress log. The raw bencoded responses glue the closing `e` to the last word, so the evidence `.txt` files are excluded from spell checking, as the torrust#2850 evidence files are. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the change removing source locations from client-visible HTTP failure reasons.
No open issues 🎉
What changed in this PR
This PR addresses #2915, the HTTP request-error portion of EPIC #2912, by removing tracker source locations from client-visible failure reasons while retaining useful error context.
Changes:
- Removes location fields and
LocatedErrorwrappers from HTTP protocol errors, and drops the crate’storrust-located-errordependency. - Updates extractors, response examples and existing tests; adds 25 regression tests covering protocol, extractor and HTTP-server behavior.
- Records before/after responses, failing/passing test runs and the error-wording comparison for maintainer review.
| File | Description |
|---|---|
packages/http-protocol/src/v1/services/peer_ip_resolver.rs |
Removes locations from peer-IP errors and tests their messages. |
packages/http-protocol/src/v1/responses/error.rs |
Updates test construction of the peer-IP error. |
packages/http-protocol/src/v1/requests/scrape.rs |
Removes scrape error locations and hides source text. |
packages/http-protocol/src/v1/requests/announce.rs |
Removes announce error locations and adds message tests. |
packages/http-protocol/src/v1/query.rs |
Removes query error locations and tests the resulting text. |
packages/http-protocol/src/v1/auth.rs |
Replaces location-bearing authentication messages with format guidance. |
packages/http-protocol/src/test_helpers.rs |
Adds a source-path assertion helper. |
packages/http-protocol/src/lib.rs |
Registers the test helper module. |
packages/http-protocol/Cargo.toml |
Removes the torrust-located-error dependency. |
packages/http-core/src/services/scrape.rs |
Adapts a test to the location-free error variant. |
packages/http-core/src/services/announce.rs |
Adapts a test to the location-free error variant. |
packages/axum-http-server/tests/server/v1/contract/mod.rs |
Registers the new failure-reason contract tests. |
packages/axum-http-server/tests/server/v1/contract/failure_reasons_hold_no_source_path.rs |
Adds 11 HTTP-server regression tests. |
packages/axum-http-server/tests/server/asserts.rs |
Adds failure-reason helpers and updates peer-IP wording. |
packages/axum-http-server/src/v1/handlers/scrape.rs |
Updates expected peer-IP error messages. |
packages/axum-http-server/src/v1/handlers/announce.rs |
Updates expected peer-IP error messages. |
packages/axum-http-server/src/v1/extractors/scrape_request.rs |
Removes location capture; updates examples and tests. |
packages/axum-http-server/src/v1/extractors/authentication_key.rs |
Removes location capture and tests authentication messages. |
packages/axum-http-server/src/v1/extractors/announce_request.rs |
Removes location capture; updates examples and tests. |
packages/axum-http-server/src/lib.rs |
Adds a source-path assertion helper for unit tests. |
docs/issues/open/2915-2912-si-3-http-tracker-request-errors/manual-verification-evidence.md |
Records reproduction, validation and the wording comparison. |
docs/issues/open/2915-2912-si-3-http-tracker-request-errors/ISSUE.md |
Updates implementation progress and acceptance evidence. |
docs/issues/open/2915-2912-si-3-http-tracker-request-errors/evidence/tests-red-http-protocol.txt |
Records the 10 protocol regression failures before the fix. |
docs/issues/open/2915-2912-si-3-http-tracker-request-errors/evidence/tests-red-axum-lib.txt |
Records the four extractor regression failures before the fix. |
docs/issues/open/2915-2912-si-3-http-tracker-request-errors/evidence/tests-red-axum-integration.txt |
Records the 11 HTTP-server regression failures before the fix. |
docs/issues/open/2915-2912-si-3-http-tracker-request-errors/evidence/tests-green.txt |
Records passing test runs after the fix. |
docs/issues/open/2915-2912-si-3-http-tracker-request-errors/evidence/responses-before.txt |
Preserves responses demonstrating the original path exposure. |
docs/issues/open/2915-2912-si-3-http-tracker-request-errors/evidence/responses-after.txt |
Preserves corresponding responses without source locations. |
cspell.json |
Excludes captured evidence text from spell checking. |
Cargo.lock |
Removes the HTTP protocol package’s located-error dependency edge. |
Review effort: Balanced
da2ce7
left a comment
There was a problem hiding this comment.
Reviewed at 69c89d7b980c9602ff597fbe89e2ab622ad9794d. Recomputed from the bytes at this head, against the merge base 36b24a9c5; git merge-tree against develop 36b24a9c5 merges without conflict and yields the head's own tree.
Process: fix-bug governs (reproduction, red test, fix, like-for-like recheck, issue-local evidence), with handle-errors-in-code, write-unit-test, commit-changes and open-pull-request. The sequence holds: the 25 tests land first in 7141f8003, every recorded red panic points at the assert_names_no_source_path call in that commit's bytes, and the test code is unchanged from there to the head.
The change against its claim: the 10 location fields and the three LocatedError sources are gone, the inner errors stay as #[source] and out of the client text, and no construction of the old shapes remains in the tree. Both percent-decoders fail only on length, so "must percent-decode to exactly 20 bytes" is exact; the key text matches AUTH_KEY_LENGTH and the alphanumeric check, and the path text matches the /announce/{key} and /scrape/{key} routes. Each of the 25 tests fails with the fix reverted. The five doc-sample length prefixes and the recorded response prefixes recompute (the two redacted lines aside, as disclosed), and all 11 "before" locations point at the capture sites at 36b24a9c5.
Consistency: no old message text survives outside the evidence; the cspell glob matches the evidence folder; the three helper copies follow rules C and E of the test-support ADR; torrust-located-error stays only in four other crates.
Hygiene: Conventional subjects with [#2915], bodies match their diffs, author equals committer; each commit carries one attribution footer, which no rule in the tree governs. git diff --check is clean, the skill's commit-id check prints nothing, and the closing-keyword scan matches only Closes #2915 in the description.
Findings: F1 (Minor) and F2 (Nit), inline; neither blocks.
Checked, no finding: the AC1 and AC2 greps reproduce empty; status: in-progress is a schema value; the EPIC row and related-pr follow the update-at-archive precedent; the leftover Location imports in http-core and the test asserts are still used.
Checks
On the loop's compute node at this head, against the merge base 36b24a9c5 (receipt server-gates-kranich-1275): the repository's pre-commit gate and lint roster exit 0 (88 s wall). This PR carries no audit record of its own, so the gate ran no validator for it. In a fresh per-PR target directory, cargo test --workspace passes 4429 tests with 0 failed and 5 ignored across 130 binaries (495 s wall), and cargo clippy --workspace --all-targets --all-features -- -D warnings is clean (102 s wall). cargo deny check exits 5 with the same 35 license rejections and four advisories as recent runs on develop, so this pull request changes nothing in that result. F2 checked against the bytes at posting: test(http-protocol): [#2915] add red tests that HTTP tracker failure reasons name no source path records 11:27:44Z as its author and committer date, while line 394 of the evidence file says 11:28:51. The head was confirmed with git ls-remote before posting. GitHub checks at this head at posting time: "Package Coverage Regression: completed/success; Package Coverage (torrust-tracker-http-core): completed/success; Package Coverage (torrust-tracker-axum-http-server): completed/success; Package Coverage (torrust-tracker-http-protocol): completed/success; Docker E2E: completed/skipped; Unit (nightly): completed/success; Documented Clippy Allows: completed/success; Shipped Features: completed/success; Workspace Packaging: completed/success; Unit (stable): completed/success; Layer Boundary Bans: completed/success; Test (Docker) (release): in_progress/pending; Discover Package Coverage: completed/success; Generate Coverage Report: completed/success; Docs Lint: completed/success; Build on ubuntu-latest (nightly): completed/success; Build on windows-latest (stable): completed/success; Build on macos-latest (nightly): completed/success; Build on ubuntu-latest (stable): completed/success; Build on windows-latest (nightly): completed/success; Build on macos-latest (stable): completed/success". At posting, develop is 36b24a9c5.
|
ACK 69c89d7 — every source location is gone from the HTTP tracker failure reasons, with its 25 red-then-green tests and its reproduction evidence recomputed from the bytes at this head |
…to the kept leading words The wording notes said every reworded message keeps the old leading words. That holds for the two `MissingParams` and the two `auth::Error` texts, not for the two `PeerIpResolutionError` texts, whose change made five handler tests and a contract-test helper change too (review finding F1 of PR torrust#2968). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ecords The evidence said the red-test commit was made at 11:28:51, the time the `git commit` command returned after its pre-commit hook; the commit records 11:27:44 as its author and committer date. State both, and say that the clean-tree check ran just before the red run started (review finding F2 of PR torrust#2968). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Record da2ce7's review 5974841608 with findings F1 (Minor) and F2 (Nit), both fixed in this branch, and Copilot's clean review. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ads of PR torrust#2968 round 1 Co-Authored-By: Claude Opus 5.5 <[email protected]>
da2ce7
left a comment
There was a problem hiding this comment.
Reviewed at a7d03b625c97ab54603d66b8397d3321144eed78. Recomputed from the bytes at this head, against the merge base 36b24a9c5; git merge-tree against develop 36b24a9c5 merges without conflict and yields the head's own tree.
Process: this round reads the four commits since 69c89d7b9 against their messages, the round 1 findings and process-pr-review with its audit template. They change the evidence and add the audit record; the code is unchanged since the last review.
The change against its claim: e10aa6316 resolves F1. The T6 note now limits the kept-leading-words claim to the two MissingParams and the two auth::Error texts and names the peer-IP exceptions, with the tests and helper that changed; the description says the same. 5d6a7e6d6 resolves F2. The evidence gives 11:27:44, the date 7141f8003 records, and 11:28:51 as the time the command returned, which is consistent with git stamping both dates before it runs the pre-commit hook. The clean-tree wording of the red run now matches tests-red-http-protocol.txt. c3d084040 adds the audit record, and a7d03b625 records the two replies and sets both rows to RESOLVED.
Consistency: the record follows the review-audit template field for field. Its review IDs, source and reply URLs, severities and resolution subjects match the forge record. Both threads carry a reply, a row and a resolution, and its verification greps reproduce at this head.
Hygiene: Conventional docs(...) subjects with [#2915], bodies match their diffs, author equals committer; each commit carries one attribution footer, which no rule in the tree governs. git diff --check is clean, the skill's commit-id check prints nothing in the head worktree, and the closing-keyword scan matches only Closes #2915 in the description.
Audit validator, logic run offline against the captured review comments: ok, 2 rows, 2 log entries, 0 failures.
Findings: none. F1 and F2 are resolved at this head.
Checked, no finding: git log -1 --format=%cI of the red commit prints 2026-11-19T11:27:44Z as quoted; the other review on the first head left no inline comment, so it needs no row; the log appends entries in time order and stamps each after the events it records; the push dismissed the earlier approval after the record was first committed.
Checks
On the loop's compute node at this head, against the merge base 36b24a9c5 (receipt server-gates-kranich-1281): the repository's pre-commit gate and lint roster exit 0 (141 s wall), and the audit validator passes this pull request's record (2 rows, 2 log entries, 0 failures). The commits since the last approved head change documentation only; the code is unchanged since 69c89d7b9, where cargo test --workspace passed 4429 tests with 0 failed and clippy was clean (receipt server-gates-kranich-1275). At the previous head c3d084040 the validator reported 2 failures (receipt server-gates-kranich-1280); this head clears them. Checked against the bytes at posting: rows F1 and F2 of docs/pr-reviews/pr-2968-review/PR-REVIEW.md read FIXED and RESOLVED. The head was confirmed with git ls-remote before posting. GitHub checks at this head at posting time: "". At posting, develop is 36b24a9c5.
|
ACK a7d03b6 — the round 1 findings are fixed in the evidence, and the review audit record's replies, rows and resolutions pass the audit validator's logic at this head |
|
ACK a7d03b6 |
Issue #2915 (SI-3 of EPIC #2912) closed with the merge of PR #2968. Sets status done, spec-path, related-pr, T6 and the remaining checkpoints, repairs the parent EPIC link, points the evidence at the new spec path, and marks SI-3 DONE in the EPIC's sub-issue table. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ssues/closed 186b657 chore(issues): archive closed issue #2915 spec to docs/issues/closed (josecelano-bot) Pull request description: Related to #2915 (SI-3 of EPIC #2912), closed on GitHub with the merge of PR #2968 on 2026-11-19. Archives the spec of issue #2915 from `docs/issues/open/` to `docs/issues/closed/`, following the `cleanup-completed-issues` skill and the SI-2 close-out (PR #2965). - Verified issue #2915 is `CLOSED` on GitHub (19:14:02Z) and the merge commit `c29699033` of PR #2968 is on `develop`. - `docs/issues/closed/2915-2912-si-3-http-tracker-request-errors/ISSUE.md`: `status: done`, `spec-path`, `related-pr: 2968`, `last-updated-utc`; T6 (wording review) marked done, since review asked for no wording change and the maintainer merged it; the parent EPIC link now points back into `open/` (`../../open/...`), because the EPIC stays in `open/`; a progress-log entry. - Checkpoints ticked: reviewer validation, the not-applicable agent-review-reports item, the committer check and the archive. Three items done at implementation time but left unticked then are ticked now, with the reason in the progress log: automatic verification and `linter all` (the pre-commit hook ran `linter all` on every commit and the pre-push hook passed on every push of PR #2968), and documentation (the extractor doc samples). - `manual-verification-evidence.md`: `issue-spec` path. The `evidence/` files move unchanged; the `cspell.json` glob `docs/issues/*/2915-...` still matches them. - `docs/issues/open/2912-remove-source-locations-from-errors/EPIC.md`: SI-3 row points to `docs/issues/closed/` and is `DONE`. - A search for `open/2915-2912` finds only the audit of PR #2968, where it is part of a recorded command; that audit is history and stays as merged. The commit-id check prints nothing. 🤖 Generated with [Claude Code](https://claude.com/claude-code) ACKs for top commit: josecelano: ACK 186b657 Tree-SHA512: e61d846588fe7cfaf7add7ae5735451bc19b78009ab202fb64d9018af14ebcce7c69da845b87f617f5cb7d9c4afb3f3bf12a4a86224cef74e6a350b2ee2b1da9
Closes #2915 (SI-3 of EPIC #2912, "Remove source locations from errors").
The
failure reasonof an HTTP tracker response held a source path of the tracker for every malformed request: a fixedLocation::caller()line, and for a shortinfo_hashalso the registry path oftorrust-info-hash(with the home directory of the account that built the tracker). This PR removes them, following the ADR "Errors do not record source locations" (docs/adrs/20261118045443_errors_do_not_record_source_locations.md).Changes
packages/http-protocol: removes thelocationfield from the 10 variants ofParseQueryError,ParseAnnounceQueryError,ParseScrapeQueryError,PeerIpResolutionErrorandauth::Error, and replaces the threeLocatedErrorsources (InvalidInfoHashParamtwice,InvalidPeerIdParam) with plain#[source]fields that are not formatted into the client text. Drops thetorrust-located-errordependency of this crate (the workspace still uses it elsewhere; SI-6 removes it).packages/axum-http-server: the announce, scrape and authentication-key extractors no longer capture a location; their module-doc sample responses show the new texts. Handler tests and one contract-test helper that matched the old peer-IP texts are updated.packages/http-core: two tests that buildPeerIpResolutionError::MissingClientIpfollow the new unit variant.cspell.json: the raw bencoded responses in the issue'sevidence/*.txtare excluded from spell checking (the closingesticks to the last word), as the Make the number of bytes non-negative by construction #2850 evidence files are.Wording for review
The four formats that printed their input only lose the trailing
in {location}. The six that printed no input are reworded; the twoMissingParamsand the twoauth::Errortexts keep the old leading words, but the two peer-IP texts keep only "missing or invalid" and "cannot get the client IP" (five handler tests and a contract-test helper changed with them). The info-hash and peer-id messages no longer print their source. The full old/new table is in the T6 section ofdocs/issues/open/2915-2912-si-3-http-tracker-request-errors/manual-verification-evidence.md. The new texts:missing query params for announce request: the URL has no query string(and the same for scrape)invalid param value {value} for info_hash: it must percent-decode to exactly 20 bytes(and the same forpeer_id)missing or invalid right-most IP in the X-Forwarded-For header, which is mandatory when the tracker runs behind a reverse proxycannot get the client IP: the server did not provide the socket address of the connectionInvalid format for authentication key param: expected 32 alphanumeric characters(the key is a secret, so it is not echoed;32isAUTH_KEY_LENGTHoftracker-core, written out becausehttp-protocoldoes not depend on it)Cannot extract authentication key param from URL path: expected /announce/<key> or /scrape/<key>Validation
manual-verification-evidence.md(V1 to V3), raw responses inevidence/.http-protocolunit tests at the parse seams, 4 extractor unit tests, 11 HTTP-server tests intests/server/v1/contract/failure_reasons_hold_no_source_path.rs, including the shortinfo_hashand shortpeer_idcases). All 25 red at the committest(http-protocol): [#2915] add red tests that HTTP tracker failure reasons name no source path, all green at the final code commit. The 14 unit tests pin the full new message.cargo test -p torrust-tracker-http-protocol -p torrust-tracker-axum-http-server -p torrust-tracker-http-corepasses; pre-commit hooks (linter all,cargo machete, doc tests) passed on every commit; the pre-push hook passed on push.Commits
test(http-protocol): [#2915] add red tests that HTTP tracker failure reasons name no source pathfix(http-protocol): [#2915] remove source locations from HTTP tracker request errorsfix(http-protocol): [#2915] replace LocatedError sources of info-hash and peer-id param errorsdocs(issues): [#2915] record the reproduction, red and green runs and the wording tableReview round 1 (da2ce7, F1 Minor and F2 Nit, both fixed):
docs(issues): [#2915] name the peer-IP messages as exceptions to the kept leading words(F1, together with this description's wording paragraph),docs(issues): [#2915] give the red-test commit time that git records(F2); the audit isdocs/pr-reviews/pr-2968-review/PR-REVIEW.md, added indocs(pr-reviews): [#2915] add the review audit of PR #2968.Out of scope and left for later sub-issues:
authentication::key::ErrorandWhitelistErrorreasons (tracker-core, SI-4 #2916), droppingtorrust-located-errorfrom the workspace (SI-6 #2918).🤖 Generated with Claude Code