refactor(vtn): split AppError into a pure to_problem() + thin axum adapter - #492
Merged
Merged
Conversation
cacoco
force-pushed
the
ccoco/vtn-error-to-problem-split
branch
from
August 24, 2026 16:15
ae8cffa to
20f4b8c
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #492 +/- ##
=======================================
Coverage 86.38% 86.39%
=======================================
Files 50 50
Lines 7309 7313 +4
=======================================
+ Hits 6314 6318 +4
Misses 995 995 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
cacoco
force-pushed
the
ccoco/vtn-error-to-problem-split
branch
2 times, most recently
from
September 3, 2026 13:58
64788ff to
312c10d
Compare
Contributor
Author
|
@stefanvi would love if you could take a look, thanks! |
cacoco
force-pushed
the
ccoco/vtn-error-to-problem-split
branch
from
September 4, 2026 21:56
312c10d to
4d892e3
Compare
stefanvi
requested changes
Sep 7, 2026
cacoco
force-pushed
the
ccoco/vtn-error-to-problem-split
branch
from
September 7, 2026 18:32
4d892e3 to
8f00630
Compare
Phase 1 of decoupling openleadr-vtn's HTTP layer from axum. AppError's IntoResponse impl mixed two concerns: computing the (StatusCode, Problem) pair for each error variant, and building an axum Response from it. Only the second part is actually axum-specific: StatusCode is http::StatusCode and Problem is a plain openleadr_wire type, so the mapping itself was already framework-neutral data. into_problem(self) -> (StatusCode, Problem) is the extracted pure function; IntoResponse now just calls it and adds the WWW-Authenticate header on 401, unchanged. Named into_problem, not to_problem, because it consumes self: clippy::wrong_self_convention flags a to_* method taking a non-Copy self by value, and into_* is the correct convention for a consuming conversion. This lets the RFC7807 mapping be reused by any adapter around AppError, not just axum's, instead of being re-implemented per framework. No behavior change, verified against the full openleadr-vtn test suite (190 passed, 0 failed, 2 pre-existing ignores). Signed-off-by: Christopher Coco <cacoco@gmail.com>
cacoco
force-pushed
the
ccoco/vtn-error-to-problem-split
branch
from
September 7, 2026 18:39
8f00630 to
59edabd
Compare
stefanvi
approved these changes
Sep 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
pub(crate) fn into_problem(self) -> (StatusCode, Problem) that maps every
variant to an RFC 7807 problem body, and a thin impl IntoResponse for
AppError that calls it and builds the axum Response (including the
WWW-Authenticate header on 401s, preserved exactly as before).
openleadr_wire::problem::Problem, both already framework-neutral types,
so this is pure code motion: the match self { ... } body moves
byte-for-byte from into_response into into_problem, with no arm's logic,
log level, or message text changed.
an AppError is axum's IntoResponse. Separating "what does this error map
to" from "how does axum render that" means the mapping can be reused by
any adapter around AppError, not just axum's, keeping the RFC 7807
semantics in one place instead of duplicated per framework.
to_* method taking a non-Copy self by value, and into_* is the correct
naming convention for a method that consumes self.
outside the crate can observe the split.
Test plan