Skip to content

fix(AWSLocation): Fixing clock skew retries #5491

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/integ-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ jobs:
- AWSKinesisVideoSignaling
- AWSLambda
- AWSLex
- AWSLocation
- AWSPinpoint
- AWSPolly
- AWSRekognition
Expand Down
41 changes: 24 additions & 17 deletions AWSLocation/AWSLocationService.m
Original file line number Diff line number Diff line change
Expand Up @@ -62,27 +62,34 @@ - (id)responseObjectForResponse:(NSHTTPURLResponse *)response
data:data
error:error];
if (!*error && [responseObject isKindOfClass:[NSDictionary class]]) {
NSString *errorTypeString = [[response allHeaderFields] objectForKey:@"x-amzn-ErrorType"];
if (!error) {
return responseObject;
}

NSString *errorTypeString = [[response allHeaderFields] objectForKey:@"x-amzn-ErrorType"];
NSString *errorTypeHeader = [[errorTypeString componentsSeparatedByString:@":"] firstObject];

if ([errorTypeString length] > 0 && errorTypeHeader) {
if (errorCodeDictionary[errorTypeHeader]) {
if (error) {
NSDictionary *userInfo = @{NSLocalizedDescriptionKey : [responseObject objectForKey:@"message"]?[responseObject objectForKey:@"message"]:[NSNull null], NSLocalizedFailureReasonErrorKey: errorTypeString};
*error = [NSError errorWithDomain:AWSLocationErrorDomain
code:[[errorCodeDictionary objectForKey:errorTypeHeader] integerValue]
userInfo:userInfo];
}
return responseObject;
} else if (errorTypeHeader) {
if (error) {
NSDictionary *userInfo = @{NSLocalizedDescriptionKey : [responseObject objectForKey:@"message"]?[responseObject objectForKey:@"message"]:[NSNull null], NSLocalizedFailureReasonErrorKey: errorTypeString};
*error = [NSError errorWithDomain:AWSLocationErrorDomain
code:AWSLocationErrorUnknown
userInfo:userInfo];
}
return responseObject;
NSString *errorDomain = nil;
NSNumber *errorCode = nil;

if (errorCodeDictionary[errorTypeHeader]) { // First, check if it's a Location error
errorDomain = AWSLocationErrorDomain;
errorCode = errorCodeDictionary[errorTypeHeader];
} else if ([[AWSService errorCodeDictionary] objectForKey:errorTypeHeader]) { // Then, check if it's a Service error
errorDomain = AWSServiceErrorDomain;
errorCode = [[AWSService errorCodeDictionary] objectForKey:errorTypeHeader];
} else { // Finally, fallback to an unknown location error
errorDomain = AWSLocationErrorDomain;
errorCode = [[NSNumber alloc] initWithInt:AWSLocationErrorUnknown];
}

NSDictionary *userInfo = @{NSLocalizedDescriptionKey : [responseObject objectForKey:@"message"]?[responseObject objectForKey:@"message"]:[NSNull null], NSLocalizedFailureReasonErrorKey: errorTypeString};
*error = [NSError errorWithDomain:errorDomain
code:[errorCode integerValue]
userInfo:userInfo];

return responseObject;
}
}

Expand Down
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

## Unreleased

-Features for next release
### Bug Fixes
- **AWSLocation**
- Fixing clock skew retries (#5491)

## 2.39.0

Expand Down
Loading