Problem
src/metrics/mod.rs contains 85 panic-prone calls (unwrap, expect, or panic!).
Evidence
src/metrics/mod.rs:41 — .expect("encoding metrics failed");
src/metrics/mod.rs:42 — String::from_utf8(buf).expect("metrics output is not valid UTF-8")
src/metrics/mod.rs:57 — HTTP_REQUESTS_TOTAL.get().expect("metrics not initialised")
src/metrics/mod.rs:63 — .expect("metrics not initialised")
src/metrics/mod.rs:69 — .expect("metrics not initialised")
Proposed fix
Replace non-essential unwrap/expect usages with typed error propagation and contextual logging. Keep explicit panics only where unrecoverable invariants are well-documented.
Acceptance criteria
- All avoidable panic-prone calls in this file are removed or justified with comments/tests.
- Error paths return typed errors and preserve observability context.
- Existing tests pass (or new tests cover changed paths).
Problem
src/metrics/mod.rscontains 85 panic-prone calls (unwrap,expect, orpanic!).Evidence
src/metrics/mod.rs:41—.expect("encoding metrics failed");src/metrics/mod.rs:42—String::from_utf8(buf).expect("metrics output is not valid UTF-8")src/metrics/mod.rs:57—HTTP_REQUESTS_TOTAL.get().expect("metrics not initialised")src/metrics/mod.rs:63—.expect("metrics not initialised")src/metrics/mod.rs:69—.expect("metrics not initialised")Proposed fix
Replace non-essential
unwrap/expectusages with typed error propagation and contextual logging. Keep explicit panics only where unrecoverable invariants are well-documented.Acceptance criteria