Skip to content

fix(fullstack): honor HTTP status in tuple FromResponse impls#5640

Open
kyle-rader-msft wants to merge 2 commits into
DioxusLabs:mainfrom
kyle-rader-msft:fix-tuple-fromresponse-status
Open

fix(fullstack): honor HTTP status in tuple FromResponse impls#5640
kyle-rader-msft wants to merge 2 commits into
DioxusLabs:mainfrom
kyle-rader-msft:fix-tuple-fromresponse-status

Conversation

@kyle-rader-msft

Copy link
Copy Markdown

Summary

Fix the tuple FromResponse implementations for (A, B) and (A, B, C) in dioxus-fullstack so they honor HTTP status codes, matching the existing single-type FromResponse behavior.

When a server function returns a tuple such as (SetHeader<SetCookie>, Json<T>) and the server responds with a non-2xx status carrying an ErrorPayload, the previous tuple implementations would:

  • ignore the HTTP status, and
  • attempt to deserialize the error body as the success type T, producing RequestError::Decode(..) instead of ServerFnError::ServerError { details: .. }.

This change checks status.is_success() in the tuple impls and, on failure, parses ErrorPayload<serde_json::Value> and returns ServerFnError::ServerError { message, code, details }. Clients using typed error enums (deserialized from details) can now reliably recover their custom error types for tuple server-function responses, just as they already can for non-tuple responses.

Testing

  • cargo test -p dioxus-fullstack --tests passes locally (rustc 1.94.0).
  • Added unit tests covering the 2xx success path and the non-2xx ErrorPayload path for both (A, B) and (A, B, C), mirroring the existing single-type FromResponse tests.
  • cargo clippy -p dioxus-fullstack --tests --all-features -- -D warnings and cargo fmt -- --check are clean.

Notes

Supersedes #5342, which was opened from a personal fork. The original fix is preserved here (rebased onto the latest main) with added test coverage. The previous PR can be closed in favor of this one.

kyle-rader and others added 2 commits June 18, 2026 17:05
The `(A, B)` and `(A, B, C)` `FromResponse` implementations ignored the
HTTP status code and always tried to decode the body as the success
type. When a server function returned a tuple such as
`(SetHeader<SetCookie>, Json<T>)` with a non-2xx status and an
`ErrorPayload`, the body was deserialized as `T`, surfacing a
`RequestError::Decode(..)` instead of the intended
`ServerFnError::ServerError { .. }`.

Check `status.is_success()` first and, on failure, parse the
`ErrorPayload` and return `ServerFnError::ServerError { message, code,
details }`, matching the single-type `FromResponse` behavior. This lets
clients recover typed errors from `details` for tuple responses just as
they already can for non-tuple responses.
Add tests for the `(A, B)` and `(A, B, C)` `FromResponse` impls covering
both the 2xx success path and the non-2xx `ErrorPayload` path, mirroring
the existing single-type `FromResponse` tests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants