MOBILE-303: Decode promo actions from the plural promoActions key#739
Draft
justSmK wants to merge 5 commits into
Draft
MOBILE-303: Decode promo actions from the plural promoActions key#739justSmK wants to merge 5 commits into
justSmK wants to merge 5 commits into
Conversation
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.
Contributor
There was a problem hiding this comment.
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
promoActionfrom the plural wire keypromoActions. - Add an explicit
encode(to:)socreateJSON()re-encodes promo actions under the same plural wire key. - Add wire-contract tests that lock down decoding + re-encoding behavior (including both
productListshapes 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.
Contributor
|
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.
Important
НЕ МЕРДЖИТЬ в develop до отведения ближайшей релизной ветки.
API возвращает
promoActions, а модель декодировала ключpromoAction— массив молча терялся с 2021 года и не доезжал до RN-моста. Фикс: ключ декодирования переименован, добавлен явныйencode(to:), чтобы перекодированный payload использовал те же wire-ключи (единственное изменение payload — появлениеpromoActions, зафиксировано guard-тестами, включая обе формыproductList). Покрыто тестами, в т.ч. анонимизированной формой реального ответа клиента; полный сьют 1229/0.