Follow-up to #1028.
CloudKitSyncEngine has six methods that touch the optional container/database. Five of them (checkAccountStatus, ensureZoneExists, pushBatch, performPull, plus push's wrapping callsite) throw SyncError.accountUnavailable when the entitlement is absent. The sixth, currentAccountId, returns nil instead:
// TablePro/Core/Sync/CloudKitSyncEngine.swift
func currentAccountId() async throws -> String? {
guard let container else { return nil }
return try await container.userRecordID().recordName
}
The single caller (`SyncCoordinator.currentAccountId` → `checkAccountStatus` at `TablePro/Core/Sync/SyncCoordinator.swift:632`) wraps it in `try? await`, so both shapes happen to work today. But the inconsistency makes the actor's contract harder to reason about: "missing entitlement" surfaces as two different things depending on which method you call.
Fix
Make currentAccountId throw, matching its peers:
func currentAccountId() async throws -> String? {
guard let container else { throw SyncError.accountUnavailable }
return try await container.userRecordID().recordName
}
Flip the matching test in TableProTests/Core/Sync/CloudKitSyncEngineTests.swift from currentAccountIdReturnsNil to expect a throw, mirroring the other five test cases.
The existing try? at the call site stays correct (it already swallows throws).
~5 lines of source + the test rename.
Follow-up to #1028.
CloudKitSyncEnginehas six methods that touch the optionalcontainer/database. Five of them (checkAccountStatus,ensureZoneExists,pushBatch,performPull, pluspush's wrapping callsite) throwSyncError.accountUnavailablewhen the entitlement is absent. The sixth,currentAccountId, returnsnilinstead:The single caller (`SyncCoordinator.currentAccountId` → `checkAccountStatus` at `TablePro/Core/Sync/SyncCoordinator.swift:632`) wraps it in `try? await`, so both shapes happen to work today. But the inconsistency makes the actor's contract harder to reason about: "missing entitlement" surfaces as two different things depending on which method you call.
Fix
Make
currentAccountIdthrow, matching its peers:Flip the matching test in
TableProTests/Core/Sync/CloudKitSyncEngineTests.swiftfromcurrentAccountIdReturnsNilto expect a throw, mirroring the other five test cases.The existing
try?at the call site stays correct (it already swallows throws).~5 lines of source + the test rename.