Skip to content

MOBILE-72: Refactor HTTP response handling to prioritize HTTP status code#692

Open
Vailence wants to merge 3 commits intodevelopfrom
feature/MOBILE-72
Open

MOBILE-72: Refactor HTTP response handling to prioritize HTTP status code#692
Vailence wants to merge 3 commits intodevelopfrom
feature/MOBILE-72

Conversation

@Vailence
Copy link
Copy Markdown
Collaborator

@Vailence Vailence commented Apr 3, 2026

Ticket: https://tracker.yandex.ru/MOBILE-72

Summary

Refactor network response handling to prioritize HTTP status code over body status field, preventing cases where 4xx/5xx responses with "Success" in body were incorrectly treated as successful.

Type of Change

  • Refactor
  • Tests

Changes

  • Restructured handleResponse in MBNetworkFetcher into smaller focused methods: makeResponseContext, handleResponseData, and per-status-code-group handlers
  • HTTP status code now determines the response handling path (2xx/3xx/4xx/5xx) before body parsing
  • Added default parameter needBaseResponse=true via NetworkFetcher protocol extension to simplify call sites
  • Simplified MBEventRepository call by using the new default parameter

Testing

  • Unit tests added/updated
  • 25 tests covering all HTTP status code groups (2xx, 3xx, 4xx, 5xx) combined with various body status values (Success, ProtocolError, ValidationError, InternalServerError, unknown, empty body, unparseable body)
  • Key scenario tested: HTTP 4xx + "Success" body status → correctly returns protocolError (not success)

Vailence added 3 commits April 2, 2026 14:40
…code

HTTP code is now the primary discriminator. Body status is only
validated within the context of the HTTP code category.
Fixes: 4xx + status "Success" no longer treated as success.
12 test cases covering all key scenarios from the API spec:
2xx/4xx/5xx with various body statuses, needBaseResponse=false,
emptyData=true, 404 special case, 3xx redirect handling.
@Vailence Vailence requested a review from justSmK April 3, 2026 13:30
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.

1 participant