Skip to content

Add protocol support for AWS JSON-RPC#645

Draft
jonathan343 wants to merge 6 commits intodevelopfrom
json-rpc-v1
Draft

Add protocol support for AWS JSON-RPC#645
jonathan343 wants to merge 6 commits intodevelopfrom
json-rpc-v1

Conversation

@jonathan343
Copy link
Contributor

Note

This PR is in rough condition and I will try improving and simplifying it, but opening this so others can start viewing it.

Overview

This PR adds end-to-end awsJson1_0/awsJson1_1 support: new protocol generators and protocol-test projections, plus smithy-aws-core runtime client protocols with awsJson-specific error identification/discriminator parsing, host-prefix handling, and event-stream support. It also includes supporting infrastructure changes: improved generated protocol test assertions/SigV4 test config, shared HTTP endpoint host-prefix merging, and smithy-json non-finite numeric serde (NaN/Infinity) round-trip support.

Testing

I was able to generate a client for Amazon SQS from its smithy service model and make successfully calls:

SQS Test Script

import asyncio

from smithy_aws_core.identity import EnvironmentCredentialsResolver
from aws_sdk_sqs.client import SQSClient, ListQueuesInput
from aws_sdk_sqs.config import Config

async def main():
    client = SQSClient(
        config=Config(
            endpoint_uri="https://sqs.us-west-2.amazonaws.com",
            region="us-west-2",
            aws_credentials_identity_resolver=EnvironmentCredentialsResolver(),
        )
    )
    response = await client.list_queues(
        ListQueuesInput()
    )
    print(response)

asyncio.run(main())

Output:

(smithy-python) $ python test.py
/Users/gytndd/dev/GitHub/smithy-python/packages/aws-sdk-signers/src/aws_sdk_signers/signers.py:794: AWSSDKWarning: Payload signing is enabled. This may result in decreased performance for large request bodies.
  warnings.warn(
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x10b598110>
ListQueuesOutput(queue_urls=['https://sqs.us-west-2.amazonaws.com/<REDACTED>.fifo', 'https://sqs.us-west-2.amazonaws.com/<REDACTED>.fifo'], next_token=None)

Next Steps

  • Test with a service/operation that uses event streaming

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@jonathan343 jonathan343 changed the title Json rpc v1 Add protocol support for AWS JSON-RPC Feb 26, 2026
writer.addImport("smithy_core.aio.utils", "async_list");

writer.write("""
def _assert_modeled_value(actual: object, expected: object) -> None:
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not a fan of this. When you do a plain assert with two dataclasses, pytest will give you a nice result showing you the diff if they're not equal. This will fail at the first non-equal value. Also, since it only recurses on dataclasses it'll never find nan in a list or map.

In the spirit of moving things out of Java, it might be best to have a test-utils package that implements an assert that builds up an error. It could go in test dependencies so normal installs don't catch it.

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.

2 participants