WeatherKit always fails with 404 for specific lat/long/dates with forecastDaily

We have an app that allows users to fetch historical weather data for their selected locations. We are seeing users report failures for specific latitudes and longitudes that come back as WeatherDaemon.WDSClient<WeatherDaemon.WeatherResource>.Errors.responseFailed

For example, this request always fails:

https://weather-data.apple.com/v3/weather/en-US/33.797/-111.775?timezone=America/Phoenix&dataSets=forecastDaily&dailyStart=2023-12-29T07:00:00Z&dailyEnd=2023-12-31T07:00:00Z&country=US&deviceLanguages=en-US&clientMetadata=<REDACTED>

Another example for another location:

https://weather-data.apple.com/v3/weather/en-AU/40.717/-74.000?timezone=America/New_York&dataSets=forecastDaily&dailyStart=2023-12-29T05:00:00Z&dailyEnd=2023-12-30T05:00:00Z&country=US&deviceLanguages=en-AU,es-AU&clientMetadata=<REDACTED>

Both example involve queries at the end of December 2023.

I have filed this as FB13608710 with example code that replicates this as it is being used in our app.

Answered by rkhamilton in 780757022

I want to update this with feedback that I received from Apple Developer Technical Support. "There is no workaround DTS can provide for the bug reports mentioned (FB13608710,FB13551253,FB13188858); they are all still under investigation."

So if you are seeing intermittent failures to download historical data using WeatherKit, or permanent failures at specific locations and dates, Apple is aware of it and it's not something you are doing wrong on your end. This includes failures where a request does not throw an error, but it silently fails to retrieve data from the middle of the range.

I have implemented a stand-alone SwiftUI view that demonstrates these failures to request historical data at this gist. You of course need to have a Xcode project with a WeatherKit Capability.

Hopefully this can be resolved by Apple, but we will be pursuing an alternate weather data vendor, as historical data availability is a tent pole of our app. Note that we have not seen problems with WeatherKit providing recent or forecast data, but it seems that historical data is not as much of a focus for WeatherKit as Time Machine was for Dark Sky. I can only imagine that few apps are relying on their historical data.

I’ll also mention that this is particularly frustrating because we also routinely see requests that initially fail with 404, but if we retry a few times (sometimes even a day later) it will eventually succeed. So we have built our app to retry a few times if we get a 404 error. However, in the cases posted above, they never succeed. It is not a good experience that we seem to get the same error from WeatherKit for queries that temporarily fail and those that permanently fail, because we will have to try to distinguish the two cases based on heuristics around how often it failed for particular dates / locations for each user. WeatherKit should really throw different errors, or return an empty array, if data is never going to be returned vs a temporary failure. Of course it should never throw an error for a valid query, but given that this is happening we would like to see better errors.

Accepted Answer

I want to update this with feedback that I received from Apple Developer Technical Support. "There is no workaround DTS can provide for the bug reports mentioned (FB13608710,FB13551253,FB13188858); they are all still under investigation."

So if you are seeing intermittent failures to download historical data using WeatherKit, or permanent failures at specific locations and dates, Apple is aware of it and it's not something you are doing wrong on your end. This includes failures where a request does not throw an error, but it silently fails to retrieve data from the middle of the range.

I have implemented a stand-alone SwiftUI view that demonstrates these failures to request historical data at this gist. You of course need to have a Xcode project with a WeatherKit Capability.

Hopefully this can be resolved by Apple, but we will be pursuing an alternate weather data vendor, as historical data availability is a tent pole of our app. Note that we have not seen problems with WeatherKit providing recent or forecast data, but it seems that historical data is not as much of a focus for WeatherKit as Time Machine was for Dark Sky. I can only imagine that few apps are relying on their historical data.

Thanks for sharing! I have seemingly ran into the same issue, with - of all places - Apple Park, Cupertino... The following code fails with status 404. It seems that trying to get any history before that date fails too, whereas getting the history after that date succeeds.

        settings.startDate = Calendar.current.date(from: .init(
            timeZone: .init(identifier: "America/Los_Angeles"),
            year: 2023,
            month: 9,
            day: 27,
            hour: 0,
            minute: 0,
            second: 0
        ))!
        settings.endDate = Calendar.current.date(from: .init(
            timeZone: .init(identifier: "America/Los_Angeles"),
            year: 2023,
            month: 9,
            day: 28,
            hour: 0,
            minute: 0,
            second: 0
        ))!
        
        settings.locationLatitude = 37.334886
        settings.locationLongitude = -122.008988
        
        let location = CLLocation(latitude: settings.locationLatitude, longitude: settings.locationLongitude)
        
        do {
            let dayWeather = try await WeatherService.shared.weather(
                for: location,
                including: .daily(startDate: settings.startDate,
                                  endDate: settings.endDate))
            
            print("Received \(dayWeather.count) DayWeather object(s).")
        } catch {
            print("WeatherKit Error: \(error.localizedDescription)")
            throw error
        }

@rkhamilton I noticed today that issues in Berlin I had reported and the issues in your code seem to have been fixed (I wrote some Unit Tests which now fail b/c "Expected failure but none recorded" :) The Apple Park issue still there but maybe will also get fixed soon.

WeatherKit always fails with 404 for specific lat/long/dates with forecastDaily
 
 
Q