Skip to content

MOBILE-303: Decode promo actions from the plural promoActions key#739

Draft
justSmK wants to merge 5 commits into
developfrom
feature/MOBILE-303-fix-promoactions-decoding-key
Draft

MOBILE-303: Decode promo actions from the plural promoActions key#739
justSmK wants to merge 5 commits into
developfrom
feature/MOBILE-303-fix-promoactions-decoding-key

Conversation

@justSmK

@justSmK justSmK commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator

Important

НЕ МЕРДЖИТЬ в develop до отведения ближайшей релизной ветки.

API возвращает promoActions, а модель декодировала ключ promoAction — массив молча терялся с 2021 года и не доезжал до RN-моста. Фикс: ключ декодирования переименован, добавлен явный encode(to:), чтобы перекодированный payload использовал те же wire-ключи (единственное изменение payload — появление promoActions, зафиксировано guard-тестами, включая обе формы productList). Покрыто тестами, в т.ч. анонимизированной формой реального ответа клиента; полный сьют 1229/0.

justSmK added 5 commits July 16, 2026 11:28
The API returns promoActions, but the model decoded the singular
promoAction key, so decodeIfPresent silently dropped the array ever
since the field was added in 2021. Hybrid bridges (React Native)
re-encode the decoded model before handing it to JS, so the promo
actions never reached the app at all.

The explicit encode(to:) keeps the re-encoded JSON on the same wire
keys as the decoder; without it the compiler synthesizes encoding from
property names, which is exactly what hid this mismatch. The public
promoAction property keeps its name to avoid an API break, and
productListItems intentionally keeps its historical encode-only key.
Locks down the promoActions decode/re-encode key, the untouched wire
keys, and both productList shapes, so the next contract drift fails a
test instead of silently dropping a field.
Anonymized shape of the sync-operation response from the client report:
fractional seconds longer than the .SSS parse pattern (ICU truncates,
doesn't shift), sibling non-Utc date keys, and boolean custom fields
that must survive re-encoding.
@justSmK
justSmK marked this pull request as draft July 16, 2026 10:06
@justSmK
justSmK requested review from Vailence, Copilot and enotniy July 16, 2026 10:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a long-standing wire-key mismatch in OperationResponse: the backend returns promo actions under promoActions (plural), but the SDK previously decoded promoAction (singular), causing the array to be silently dropped and never reach the hybrid bridge payload.

Changes:

  • Decode promoAction from the plural wire key promoActions.
  • Add an explicit encode(to:) so createJSON() re-encodes promo actions under the same plural wire key.
  • Add wire-contract tests that lock down decoding + re-encoding behavior (including both productList shapes and a production-shaped payload).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
Mindbox/Model/OperationResponse.swift Fixes decoding key to promoActions and ensures encoding matches wire keys via explicit encode(to:).
MindboxTests/Network/OperationResponseTests.swift Adds regression tests covering promoActions decode/encode and guarding existing bridge payload behavior.
Mindbox.xcodeproj/project.pbxproj Registers the new test file in the test target build sources.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions

Copy link
Copy Markdown
Contributor
TestsPassed ✅SkippedFailedTime ⏱
Unit tests report1336 ran1336 ✅1m 57s 186ms

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