Skip to content

Commit 1a140ae

Browse files
committed
docs(issues): [torrust#1823] add keep-vs-delete analysis to located-error rename spec
Record pre-implementation review of whether torrust-tracker-located-error should be kept and renamed or removed entirely. Recommendation: keep and rename. Awaiting reviewer confirmation in the draft PR before starting T1.
1 parent fc409ef commit 1a140ae

1 file changed

Lines changed: 91 additions & 1 deletion

File tree

docs/issues/open/1823-1669-10-rename-torrust-tracker-located-error-to-torrust-located-error.md

Lines changed: 91 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ github-issue: 1823
77
spec-path: docs/issues/open/1823-1669-10-rename-torrust-tracker-located-error-to-torrust-located-error.md
88
branch: 1823-rename-torrust-tracker-located-error-to-torrust-located-error
99
related-pr: null
10-
last-updated-utc: 2026-05-21 17:00
10+
last-updated-utc: 2026-05-21 17:15
1111
semantic-links:
1212
skill-links:
1313
- create-issue
@@ -51,6 +51,95 @@ the old published name (deprecation notice, then yank after downstream migration
5151
This issue is a subissue of EPIC [#1669](../open/1669-overhaul-packages/EPIC.md)
5252
(Overhaul: Packages).
5353

54+
## Pre-Implementation Review: Keep vs. Delete
55+
56+
Before starting the rename, we reconsidered whether the package itself should exist or be
57+
removed. The conclusion below should be reviewed and confirmed in the PR before T1–T13 are
58+
executed.
59+
60+
### Recommendation
61+
62+
**Keep the package and proceed with the rename to `torrust-located-error`.**
63+
64+
### What the package actually provides
65+
66+
The crate is ~110 lines in a single file (`packages/located-error/src/lib.rs`) with one
67+
runtime dependency (`tracing`). It exports:
68+
69+
- `Located<E>` — newtype wrapper used as the conversion entry point.
70+
- `LocatedError<'a, E>` — the decorated error: `Arc<E>` source + `Box<Location<'a>>`.
71+
- `DynError``Arc<dyn Error + Send + Sync>` type alias.
72+
- A `#[track_caller]` `Into` impl that captures `Location::caller()` and emits
73+
`tracing::debug!` on construction.
74+
75+
Non-trivial value vs. `std` / `thiserror` alone:
76+
77+
1. `#[track_caller]` capture into a stored `Location` (std has no first-class equivalent).
78+
2. `Arc`-shared source making the error cheaply `Clone` even for `!Clone` inner errors.
79+
3. Automatic `tracing::debug!` log on construction (single attachment point for tracing).
80+
4. Works for both concrete `E: Error` and `dyn Error + Send + Sync`.
81+
82+
### Current workspace usage
83+
84+
Active in **5 packages**, ~20 call sites:
85+
86+
| Package | Files | Usage |
87+
| ---------------- | ---------------------------------------------------------------------------------------------------------- | ------------------------------ |
88+
| `configuration` | `src/lib.rs` | 3 error variants (dyn) |
89+
| `axum-server` | `src/tsl.rs` | TLS error variant (dyn) |
90+
| `http-protocol` | `src/v1/requests/announce.rs`, `src/v1/requests/scrape.rs` | info_hash / peer-id conversion |
91+
| `tracker-core` | `src/error.rs`, `src/authentication/key/mod.rs`, `src/authentication/handler.rs`, `src/databases/error.rs` | many error variants |
92+
| `tracker-client` | `src/udp/mod.rs` | uses `DynError` alias |
93+
94+
The package is also referenced from
95+
[`.github/skills/dev/rust-code-quality/handle-errors-in-code/SKILL.md`](../../../.github/skills/dev/rust-code-quality/handle-errors-in-code/SKILL.md)
96+
as the recommended pattern for diagnostics-rich errors.
97+
98+
### Why keep it
99+
100+
- **Real, non-trivial functionality.** The `#[track_caller]` + `Arc`-clone + auto-trace
101+
combo is not a one-liner. Replacing it everywhere would either duplicate the pattern
102+
across 5 packages or drop diagnostic features.
103+
- **Stable surface, near-zero maintenance cost.** Single file, one dep, hasn't changed
104+
materially in a long time.
105+
- **Crates.io alternatives are worse fits.** `error-stack` / `eyre` / `anyhow` are heavier
106+
and don't compose cleanly with the `thiserror`-enum policy. The error-handling skill
107+
explicitly disallows `anyhow` in libraries.
108+
- **Removal cost is high, benefit is low.** Deleting would touch ~20 call sites across
109+
core domain packages just to swap to a less expressive pattern.
110+
- **The rename premise still holds.** Nothing in the implementation is tracker-specific.
111+
`torrust-located-error` correctly reflects scope and is reusable by `torrust-index`.
112+
113+
### Why delete it (the alternative case)
114+
115+
For completeness, reasons one might prefer deletion:
116+
117+
- **Niche pattern.** Locating an error to a `Location` is most useful when the wrapped
118+
error type is `!Display`/opaque (e.g. `Box<dyn Error>`). Where call sites use concrete
119+
`thiserror` enums with `#[from]`, the `?` operator already propagates source-chain
120+
information and the `Location` adds limited extra signal.
121+
- **Tracing overlap.** `tracing` spans / `instrument` can carry caller metadata; some of
122+
the value of `Located` is already available from structured logging at error sites.
123+
- **Few real beneficiaries.** Of the ~20 call sites, several store `LocatedError<dyn ...>`
124+
variants that are rarely matched on; a plain `Box<dyn Error + Send + Sync>` source
125+
field plus a `tracing::error!` at construction may be sufficient.
126+
- **One less crate to publish/maintain** on crates.io if the value is mostly cosmetic.
127+
128+
These points are weaker than the "keep" reasons above given the current usage, but they
129+
are why this question is worth confirming with a reviewer before committing to a rename
130+
131+
- publish + downstream migration.
132+
133+
### Decision needed before implementation
134+
135+
If the reviewer agrees with **Keep**, T1–T13 proceed as planned.
136+
137+
If the reviewer prefers **Delete**, this subissue is closed and replaced by a new
138+
subissue with scope: remove `packages/located-error`, migrate ~20 call sites to a
139+
simpler pattern (likely `Box<dyn Error + Send + Sync>` + explicit `tracing::error!` at
140+
construction sites), yank `torrust-tracker-located-error` from crates.io with a final
141+
deprecation note.
142+
54143
## Scope
55144

56145
### In Scope
@@ -129,6 +218,7 @@ Status values: `TODO`, `IN_PROGRESS`, `BLOCKED`, `DONE`.
129218

130219
- 2026-05-15 12:00 UTC - josecelano - Spec drafted as subissue of EPIC #1669
131220
- 2026-05-21 17:00 UTC - josecelano - GitHub issue #1823 created and linked as sub-issue of #1669; spec moved to `docs/issues/open/`
221+
- 2026-05-21 17:15 UTC - josecelano - Added pre-implementation "Keep vs. Delete" analysis; awaiting reviewer decision before T1 starts
132222

133223
## Acceptance Criteria
134224

0 commit comments

Comments
 (0)