Skip to content

Commit ba0c759

Browse files
sunnylqmclaude
andcommitted
fix: address CodeRabbit review on PR #606
- iOS: classify the patch-manifest JSON parse error as PATCH_FAILED; it previously fell through unclassified and the downloadUpdate fallback mislabeled it DOWNLOAD_FAILED even though the download itself had succeeded - type EventData.code as UpdateErrorCode instead of a loose string for compile-time protection against typo'd codes Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 414f020 commit ba0c759

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

ios/RCTPushy/RCTPushy.mm

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,10 @@ - (void)applyPatchForHash:(NSString *)hash
693693
NSError *error = nil;
694694
id jsonObject = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:&error];
695695
if (error != nil) {
696-
callback(error);
696+
// Classify as a patch failure like the sibling manifest branches;
697+
// unclassified errors would otherwise be tagged DOWNLOAD_FAILED by the
698+
// downloadUpdate fallback even though the download itself succeeded.
699+
callback(PushyErrorWithCode(pushy::error_codes::kPatchFailed, error.localizedDescription));
697700
return;
698701
}
699702
if (![jsonObject isKindOfClass:[NSDictionary class]]) {

src/type.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import type { UpdateErrorCode } from './error';
2+
13
export interface VersionInfo {
24
name: string;
35
hash: string;
@@ -61,8 +63,8 @@ export type EventType =
6163
| 'errorInstallApk';
6264

6365
export interface EventData {
64-
/** Stable machine-readable error code (see UpdateErrorCode); present on error events */
65-
code?: string;
66+
/** Stable machine-readable error code; present on error events */
67+
code?: UpdateErrorCode;
6668
currentVersion: string;
6769
cInfo: {
6870
rnu: string;

0 commit comments

Comments
 (0)