Skip to content

Conversation

@jbelkins
Copy link
Contributor

@jbelkins jbelkins commented Oct 22, 2025

Description of changes

Currently, when a response contains invalid JSON, the error is caught & not rethrown, and the response body is treated as an empty JSON object {}.

This can lead to misleading responses, i.e. leading the caller to believe that the request succeeded but returned no results versus that it was not parseable.

  • The guard that handles the empty-response case now has some commentary to explain why it's there.
  • Our JSON parser was set to allow fragments. This is not needed for SDK use and is removed. (A couple tests had to have their setup altered to accommodate this, since they were using fragments for simplicity of setup.)
  • We were catching the NSError that is thrown when JSON is invalid, and converting it to a successful response. That catch is now removed.
  • Empty bodies are explicitly allowed by JSON-based AWS protocols, and are generally to be treated as an empty JSON object {}. That behavior is unchanged.

To be determined: figure out exactly what error should be thrown back to the caller, create it and throw it.

This is a breaking change in that it alters the SDK's behavior from "empty success" to throwing when unparseable data is encountered in a response.

Scope

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

let traceInterceptor = TraceInterceptor<TestInput, TestOutput, HTTPRequest, HTTPResponse>(trace: trace)
let builder = OrchestratorBuilder<TestInput, TestOutput, HTTPRequest, HTTPResponse>()
.attributes(attributes)
.serialize({ input, builder, _ in
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests below used JSON fragments (i.e. a JSON string only) for serde since fragments were allowed and it kept the test setup simpler. Tests now serialize JSON objects.

@jbelkins jbelkins changed the title fix: Throw error on invalid JSON in response fix!: Throw error on invalid JSON in response Oct 24, 2025
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

Successfully merging this pull request may close these issues.

1 participant