Skip to content

Conversation

@mla
Copy link
Contributor

@mla mla commented Aug 12, 2025

Summary

This PR fixes a bug where the RestJSON template incorrectly adds _stream_param to ALL response classes that have a payload property, even when those payloads contain JSON data (not binary streams). This causes JSON responses to be returned as unparsed strings instead of being properly deserialized.

The Problem

The current template adds _stream_param whenever a response shape has a payload property:

[%- IF (shape.payload) -%]
use MooseX::ClassAttribute;
class_has _stream_param => (is => 'ro', default => '[% c.to_payload_shape_name(shape.payload) %]');
[%- END %]

This affects services like Pinpoint, where SendMessagesResponse has a JSON payload but was incorrectly marked as a stream, causing the JSON to not be parsed.

The Solution

Check if the payload member explicitly has streaming == 1 before adding _stream_param:

[%- IF (shape.payload) -%]
  [%- payload_member = shape.members.item(shape.payload) -%]
  [%- IF (payload_member.streaming == 1) -%]
use MooseX::ClassAttribute;
class_has _stream_param => (is => 'ro', default => '[% shape.payload %]');
  [%- END -%]
[%- END %]

Impact

  • Fixed: JSON responses (Pinpoint, AppMesh, etc.) are now properly parsed
  • Preserved: Binary/streaming responses (S3, Glacier, MediaStore) still work correctly
  • Backward Compatible: Only affects response parsing behavior, no API changes

Testing

Added test t/99_stream_param_bug.t that verifies:

  • Pinpoint responses don't have _stream_param (JSON)
  • S3 responses still have _stream_param (binary)
  • JSON responses are properly parsed, not returned as strings

All 11 tests pass with this fix.

Real-World Impact

This bug was discovered when AWS Pinpoint SMS sending failed after a Paws upgrade - the JSON response wasn't being parsed, breaking error handling and response processing logic.

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