Yannick Guern opened merge request !29: feat: enrich Warp 10 error logging with structured context and response bodies at Yannick Guern / Pain Recorder

Yannick Guern
2026-02-14T12:11:13Z

Summary

Enrich all Warp 10 client error log entries with structured context (operation parameters, HTTP status, truncated response bodies) and add handler-level error logging for pain recording and timeline retrieval.

Changes

Client-level (src/warp10.rs)

Add truncate_for_log helper for safe string truncation at character boundaries

Refactor map_reqwest_error to take reference, enabling caller logging before conversion

All 4 methods (ingest, exec, delete, fetch) now include:

Operation-specific context (point_count, script_preview, class, label_count, time_range)

HTTP status code on every error branch

Truncated response_body (500 chars max, <empty> / <no response>)

Reqwest-level error logging with detail field (previously silent on timeout/network)

Handler-level (src/pain/handlers.rs, src/auth/handlers.rs)

record_pain(): Error logged with sid, pain_level, point_count

get_pain_timeline(): Error logged with sid, date_range, timezone

unregister(): Existing delete log enriched with class pattern field

Key design decisions

Two-level logging: client logs technical context, handlers log business context

sid session read moved before Warp 10 calls so it's available on error paths

No sensitive data in logs: tokens, UUIDs, PII excluded (FR-006)

Validation

cargo fmt: PASS

cargo clippy: PASS

cargo nextest run: 59/59 tests pass (zero modifications to existing tests)

Security audit: No PII in any log field

Spec

See specs/032-warp10-error-logging/ for full specification, plan, and research.