Skip to content
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

Error JSON-object decoding based on HTTP Status Code #6

Open
tasanobu-zz opened this issue May 21, 2019 · 0 comments
Open

Error JSON-object decoding based on HTTP Status Code #6

tasanobu-zz opened this issue May 21, 2019 · 0 comments

Comments

@tasanobu-zz
Copy link

Currently there are some cases that error objects in JSON format are not properly decoded.

__type is assigned to the raw value of CodingKeys.type at here for JSON content payload, and it works fine in case that an error code is set to __type field in JSON object. (e.g. DynamoDB)
However, there are some services (e.g. rds-data, api-gateway) where error code is decided based on HTTP Status Code. Generated code for such services does not work.

Example case

rds-data returns an error JSON object like below.

{"message":"Unknown database 'non-existing-database'"}

The error JSON decoding fails and the error below is raised because there is no __type field.

keyNotFound(CodingKeys(stringValue: "__type", intValue: nil), Swift.DecodingError.Context(codingPath: [], debugDescription: "No value associated with key CodingKeys(stringValue: \"__type\", intValue: nil) (\"__type\").", underlyingError: nil))

Question

I'm wondering if it would be possible to solve this issue by passing a specific delegate name to HttpClientConfiguration.clientDelegateNameOverride in a configuration (e.g. RDSConfiguration.swift). That delegate name is used in ModelClientDelegate. addJsonDelegate instead of JSONAWSHttpClientDelegate.

The questions are

  • where the delegate struct should be implemented? (maybe, in smoke-aws)
  • If the delegate struct is implemented correctly at a right place, would the solution above work? (as long as the delegate struct decides error based on HTTP Status Code.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant