HKStatisticsCollectionQuery initialResultsHandler returns nil results (error) for one specific user — read auth granted, data exists, survives reinstall

Environment: iPhone 13 Pro, iOS 26.5. Affects a single user out of many; cannot reproduce on any of our test devices.

We use HKStatisticsCollectionQuery to read step counts for a statistics screen. For one specific user, the query's initialResultsHandler appears to deliver results == nil (the success branch never runs), so our completion is never called and the screen shows an infinite spinner.

private let store = HKHealthStore()

func fetchHourlyStepCounts(for day: Date, completion: @escaping ([Int]) -> Void) {
    guard let stepType = HKQuantityType.quantityType(forIdentifier: .stepCount) else { return }

    let calendar = Calendar.current
    let startOfDay = calendar.startOfDay(for: day)
    var hourly = DateComponents()
    hourly.hour = 1

    let query = HKStatisticsCollectionQuery(
        quantityType: stepType,
        quantitySamplePredicate: nil,
        options: .cumulativeSum,
        anchorDate: startOfDay,
        intervalComponents: hourly
    )

    query.initialResultsHandler = { _, collection, error in
        guard let collection else {
            // For the affected user, execution seems to reach here (collection == nil).
            // Adding logging of the HKError + authorization status for the next occurrence.
            return
        }

        var counts: [Int] = []
        let end = calendar.date(byAdding: .day, value: 1, to: startOfDay)!
        collection.enumerateStatistics(from: startOfDay, to: end) { stats, _ in
            let steps = stats.sumQuantity()?.doubleValue(for: .count()) ?? 0
            counts.append(Int(steps))
        }
        DispatchQueue.main.async { completion(counts) }
    }

    store.execute(query)
}

What we've confirmed / ruled out:

  • Read authorization for stepCount is granted (the user toggled it ON in the HealthKit sheet on video).
  • The Apple Health app shows step data for this user (so data exists).
  • A coarser query (2-year interval) for the same user succeeds, while the hourly query appears to fail — same type / predicate / options / auth.
  • Symptom persists across app reinstall and device reboot, and re-granting Health permission.
  • Permission denial returns empty results (per Apple docs), not an error — so this isn't simple denial.
  • Not errorDatabaseInaccessible as far as we can tell (foreground, device unlocked).

Questions:

  1. What can cause HKStatisticsCollectionQuery.initialResultsHandler to return results == nil (with an error) persistently for one device/account, when read auth is granted and data exists?
  2. Can errorHealthDataRestricted occur without an MDM/supervised profile (i.e., on a normal consumer device)? What device/account states actually trigger it?
  3. Is it expected that a coarse-interval query succeeds while an hourly-interval query on the same type fails for the same user?

We're adding logging of the actual HKError code + authorizationStatus for the next occurrence, but would appreciate any insight on what conditions produce this.

HKStatisticsCollectionQuery initialResultsHandler returns nil results (error) for one specific user — read auth granted, data exists, survives reinstall
 
 
Q