Skip to content

MOBILE-230: Fix sync operation error delivery and date-migration hour cycle#728

Merged
Vailence merged 4 commits into
developfrom
feature/MOBILE-230
Jun 29, 2026
Merged

MOBILE-230: Fix sync operation error delivery and date-migration hour cycle#728
Vailence merged 4 commits into
developfrom
feature/MOBILE-230

Conversation

@Vailence

Copy link
Copy Markdown
Collaborator

Description

Three related MOBILE-230 fixes around sync operations and the date-format migration.

Sync operations (Mindbox.swift)

  • executeSyncOperation no longer drops the completion handler when the operation body is invalid JSON — the caller now always gets a result.
  • Invalid operation name / invalid JSON now consistently deliver .validationError across all sync overloads, instead of failing silently.

Date-format migration (DateFormatMigration.swift)

  • Fixed the hour-cycle override when building legacy formatters. iOS encodes the device 12h/24h setting into Locale.current as an @hours= keyword, so appending a second hours= produced a duplicate (…@hours=h12;hours=h23) that ICU resolves to the first occurrence — silently defeating the override and leaving every candidate on the device's own hour cycle.
  • Now any pre-existing hours/hc keyword is stripped before forcing the cycle (other keywords like language/region/calendar preserved), so legacy values written under the opposite hour cycle parse and migrate correctly.

Type of Change

  • Bug fix

Test Procedure

  • Added/extended MindboxOperationsTests for the sync-operation error paths.
  • DateFormatMigrationTests (11 tests) — including the previously-failing runConvertsLegacyInstallationDateWrittenIn24hFormat() — now pass.
  • Full suite green: 1055 / 1055 on iPhone 16 Pro (iOS 18.5).

@Vailence Vailence requested a review from justSmK June 26, 2026 11:19
@github-actions

github-actions Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor
TestsPassed ✅SkippedFailedTime ⏱
Unit tests report1201 ran1201 ✅1m 39s 289ms

@justSmK

justSmK commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

Обновляй ветку через rebase, чтобы история линейная получалась

Comment thread Mindbox/Mindbox.swift Outdated
Comment thread Mindbox/Mindbox.swift Outdated
Comment thread MindboxTests/MindboxOperationsTests.swift
Vailence added 4 commits June 29, 2026 14:05
Previously, passing an invalid JSON string to executeSyncOperation(json:completion:)
caused the operation to be silently dropped on eventQueue without ever invoking the
completion handler. This violated the public contract (completion always arrives on
the main thread, either as .success or .failure).

Fix: deliver .failure(.internalError(.parsing)) on the main thread when JSON validation
fails, matching the delivery pattern used by MBEventRepository.send<T> for all other
error paths.

Test: syncInvalidJSONDeliversFailureOnMain asserts the completion is called as .failure
on the main thread, and will fail (timeout ~10s) rather than hang if the regression recurs.
…c overloads

All three executeSyncOperation overloads now call completion(.failure(.validationError(...)))
on the main thread when an invalid operation name is passed, matching the DoD requirement.

The invalid-JSON branch in enqueueSyncEvent is unified through the same failSyncOperation
helper, so both client-side validation paths produce a consistent .validationError with
a ValidationMessage describing the failure location.

Added test: syncInvalidNameDeliversFailureOnMain pins the regression for the name path.
Locale.current encodes the device 12h/24h setting as an @Hours= keyword,
so appending a second hours= produced a duplicate that ICU resolved to the
first occurrence — defeating the override and leaving every legacy formatter
on the device's own hour cycle. Strip any pre-existing hours/hc keyword
before forcing the cycle so values written under the opposite cycle parse.
Parameterize failSyncOperation location so invalid JSON reports
operationBody instead of operationSystemName, fix the misleading
.parsing doc comment, and assert the error type and location in tests.
@Vailence Vailence force-pushed the feature/MOBILE-230 branch from 714d7c0 to 9e214fa Compare June 29, 2026 09:05
@Vailence Vailence requested a review from justSmK June 29, 2026 09:15
@Vailence Vailence merged commit d007dc9 into develop Jun 29, 2026
7 checks passed
@Vailence Vailence deleted the feature/MOBILE-230 branch June 29, 2026 13:44
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