We’re seeing a similar issue and have filed FB24943335 with reproduction details and probe results.
HKStatisticsCollectionQuery reproducibly fails for certain historical heart-rate ranges with:
Unable to invalidate interval: no data source available. [com.apple.healthkit 3]
The underlying samples are readable with HKSampleQuery, and HKStatisticsQuery succeeds for the same ranges, including with .separateBySource. The collection query fails both with and without source separation.
Narrowing the date range can make the collection query succeed while keeping the anchor date and interval components unchanged. Some successful narrower queries fully contain the same long-duration Watch samples, alongside WHOOP samples. Immediately repeating the original larger range still fails.
Condensed workout samples may be relevant, but we haven’t established the trigger or whether this shares the same root cause as FB22221658.
One caveat for anyone trying subdivision: using both .strictStartDate and .strictEndDate can exclude samples spanning a split boundary. Recovering nonempty buckets therefore doesn’t necessarily mean the resulting statistics are complete.