[ECO-5611] Address nullability change in ARTAnnotation initializer and timestamp property#2177
[ECO-5611] Address nullability change in ARTAnnotation initializer and timestamp property#2177
Conversation
WalkthroughAdds a new nullable-friendly ARTAnnotation initializer (omitting encoding/timestamp/serial), updates call sites to use it, changes Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
Pre-merge checks and finishing touches✅ Passed checks (5 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Jira integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (5)
Source/ARTAnnotation.mSource/ARTRealtimeAnnotations.mSource/ARTRestAnnotations.mSource/PrivateHeaders/Ably/ARTAnnotation+Private.hSource/include/Ably/ARTAnnotation.h
💤 Files with no reviewable changes (1)
- Source/ARTRestAnnotations.m
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-12-10T14:14:47.456Z
Learnt from: lawrence-forooghian
Repo: ably/ably-cocoa PR: 2162
File: Source/ARTJsonLikeEncoder.m:522-525
Timestamp: 2025-12-10T14:14:47.456Z
Learning: In Source/ARTJsonLikeEncoder.m, ensure that artMessage.actionIsInternallySet is only set to YES when the SDK explicitly sets the action field (e.g., in ARTMessage initWithName:data:). Messages decoded from the wire must not have actionIsInternallySet set, even if they contain an action field, because the flag should distinguish SDK-internal actions from wire-provided actions. Apply this behavior broadly to Objective-C files in the Source directory that involve message encoding/decoding, and add tests to verify that decoding does not flip the flag.
Applied to files:
Source/ARTAnnotation.mSource/ARTRealtimeAnnotations.m
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
- GitHub Check: check (iOS, test_iOS18_4)
- GitHub Check: check (macOS, test_macOS)
- GitHub Check: check (tvOS, test_tvOS18_4)
- GitHub Check: build
- GitHub Check: check
- GitHub Check: check
🔇 Additional comments (5)
Source/ARTRealtimeAnnotations.m (1)
131-139: LGTM! Verify default values for omitted fields.The conversion now uses the new internal initializer without
encoding,timestamp, andserial. This correctly addresses the nullability issue for outbound annotations.Confirm that leaving
encoding,timestamp, andserialasnilis the expected behavior for annotations being published. The server should presumably assign these values.Source/include/Ably/ARTAnnotation.h (2)
83-84: LGTM! Provides convenient factory method.The addition of the class factory method
+newWithAnnotationType:alongside the instance initializer provides a convenient way to create ARTEvent instances. The implementation correctly delegates to the instance initializer.
71-71: Timestamp parameter design is intentional, not contradictory.The public initializer requires
timestamp(non-nullable at line 71), but the private initializer inARTAnnotation+Private.h(lines 19-26) omits the timestamp parameter entirely, specifically for "converting outbound annotations to annotations before publishing." The nullabletimestampproperty (line 50) allows for nil values once created. This design—strict public API with flexible private API—is intentional and supports outbound annotation conversion without contradicting the PR objective.Source/ARTAnnotation.m (2)
176-182: LGTM! Standard factory method pattern.The implementation correctly provides both an instance initializer and a class factory method. The factory method properly allocates and initializes using the instance method.
39-60: This initializer intentionally omitsencoding,timestamp, andserialas it's designed for outbound annotations being prepared for publication. These nil values are properly handled: theartAddEncodingmethod explicitly manages nil encoding via a ternary operator, whiletimestampandserialare not accessed during the publish/encode flow. No action required.
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
Source/include/Ably/ARTAnnotation.h (1)
83-84: Redundant method declarations in ARTEvent category.Both an instance method
-initWithAnnotationType:(line 83) and a class factory method+newWithAnnotationType:(line 84) are declared. This creates ambiguity:
- If the class factory method is the intended API, remove the instance method
- If both are intentional, clarify the use case for each
Typically, when adding a class factory method, the corresponding instance initializer is kept private or removed from the public interface.
🔎 Check usage of both methods
#!/bin/bash # Verify which method is actually used in the codebase # Search for calls to instance method rg -n "\[\[.*alloc\].*initWithAnnotationType:" --type=m # Search for calls to class factory method rg -n "\[.*newWithAnnotationType:" --type=m # Check implementation in ARTEvent category fd -e m -e h ARTEvent | xargs rg -n "AnnotationType"
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Jira integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (2)
Source/ARTJsonLikeEncoder.mSource/include/Ably/ARTAnnotation.h
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-12-10T14:14:47.456Z
Learnt from: lawrence-forooghian
Repo: ably/ably-cocoa PR: 2162
File: Source/ARTJsonLikeEncoder.m:522-525
Timestamp: 2025-12-10T14:14:47.456Z
Learning: In Source/ARTJsonLikeEncoder.m, ensure that artMessage.actionIsInternallySet is only set to YES when the SDK explicitly sets the action field (e.g., in ARTMessage initWithName:data:). Messages decoded from the wire must not have actionIsInternallySet set, even if they contain an action field, because the flag should distinguish SDK-internal actions from wire-provided actions. Apply this behavior broadly to Objective-C files in the Source directory that involve message encoding/decoding, and add tests to verify that decoding does not flip the flag.
Applied to files:
Source/ARTJsonLikeEncoder.m
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
- GitHub Check: check (macOS, test_macOS)
- GitHub Check: check
- GitHub Check: check (iOS, test_iOS18_4)
- GitHub Check: check (tvOS, test_tvOS18_4)
- GitHub Check: build
- GitHub Check: check
Closes #2125, #2124
Summary by CodeRabbit
Refactor
API Changes
Bug Fix / Behavior
✏️ Tip: You can customize this high-level summary in your review settings.