For the iOS/Xcode age range validation, what is an invalidRequest error?

One of the responses to a call to AgeRangeService.shared.requestAgeRange is AgeRangeService.Error.invalidRequest.

This has no documentation. What on earth is an invalid request - I mean the app just calls the API, there's no parameters supplied or anything, how can the request ever be invalid?

If the app calls AgeRangeService.shared.requestAgeRange and gets this as a response then what is the app supposed to do with that?

Answered by DTS Engineer in 863752022

The .invalidRequest error can be returned for a variety of reasons. My favourite one is passing in a negative age (-:

let response = try await AgeRangeService.shared.requestAgeRange(ageGates: 13, -1, 18, in: self)
// throws `.invalidRequest`

Are you asking because you’re seeing this error? Or because you’re trying to decide how to handle the error?

If it’s the latter, I think that’s a policy decision for you to make. This API exists so you can gate access to resources. If it throws an unexpected error, you have to decide whether to fail open or fail closed.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

The .invalidRequest error can be returned for a variety of reasons. My favourite one is passing in a negative age (-:

let response = try await AgeRangeService.shared.requestAgeRange(ageGates: 13, -1, 18, in: self)
// throws `.invalidRequest`

Are you asking because you’re seeing this error? Or because you’re trying to decide how to handle the error?

If it’s the latter, I think that’s a policy decision for you to make. This API exists so you can gate access to resources. If it throws an unexpected error, you have to decide whether to fail open or fail closed.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

@eskimo

Hello

"Or because you’re trying to decide how to handle the error?"

Yes. In the example you gave that's a compile-time programming error. I'd like to know if there are any errors that can occur at run time for example and are re-tryable, for example any errors caused by connectivity failures, in which case if the app tried again then next time the failure might succeed?

Inspired by this thread I bumped WWDC 2025 Session 299 Deliver age-appropriate experiences in your app to the front of the EskimoTV queue, and that made it clear that .invalidRequest indicates a programming error. Start here in the video.

I encourage you to file a bug against the docs to make this clearer.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

For the iOS/Xcode age range validation, what is an invalidRequest error?
 
 
Q