Skip to content

Conversation

jonathan343
Copy link
Contributor

@jonathan343 jonathan343 commented Sep 15, 2025

Overview

When generating a client for a service that uses REST-JSON or AWS Event Streaming, the client is unusable after install (see "Error Examples" section below) due to nothing taking a dependency on smithy-json or smith-aws-event-stream.

This PR adds the following:

  • Adds a json optional dependency group that includes smithy-json.
  • Updates the code generator to include a smithy-aws-core[eventstream] dependency in pyproject.toml when operations with event streaming are added.
  • Updates the code generator to include a smithy-aws-core[json] dependency in pyproject.toml when generating services that support REST-JSON.

Dependencies Before and After

Dependencies Before Fix

# in pyproject.toml

dependencies = [
    "smithy_aws_core<0.1.0",
    "smithy_core<0.1.0",
    "smithy_http[awscrt]<0.1.0"
]

Dependencies After Fix

# in pyproject.toml

dependencies = [
    "smithy_aws_core[eventstream, json]<0.1.0",
    "smithy_core<0.1.0",
    "smithy_http[awscrt]<0.1.0"
]

Error Examples

Error without smithy-json

ModuleNotFoundError: No module named 'smithy_json'

Error without smithy-aws-event-stream

smithy_core.exceptions.MissingDependencyError: Attempted to use event streams, but smithy-aws-event-stream is not installed.

Alternative Option

Add a direct dependency on smithy-json and smith-aws-event-stream:

# in pyproject.toml

dependencies = [
    "smithy_aws_core<0.1.0",
    "smithy_aws_event_stream<0.1.0",
    "smithy_core<0.1.0",
    "smithy_http[awscrt]<0.1.0",
    "smithy_json<0.1.0"
]

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 requested a review from a team as a code owner September 15, 2025 20:25
nateprewitt
nateprewitt previously approved these changes Sep 15, 2025
@SamRemis
Copy link
Contributor

To document a conversation we had on slack:

We decided against the alternate option (requiring the dependencies directly) since it's odd to add a direct dependency requirement on something we will depend on transitively.

It would make it much more difficult to reason about why a dependency is needed, and when it's safe to remove. Depending directly on a package because a dependency needs it creates confusion about ownership and purpose - if the transitive dependency changes its requirements or is removed entirely, we'd be left with direct dependencies that serve no clear purpose in our codebase. This approach also makes dependency management more complex, as we'd need to track both our actual needs and the needs of our dependencies, potentially leading to version conflicts or unnecessary bloat.

"smithy-aws-event-stream"
]
json = [
"smithy-json"
Copy link
Contributor Author

@jonathan343 jonathan343 Sep 16, 2025

Choose a reason for hiding this comment

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

Note: In this repo, all our dependencies on smithy-* packages are unbounded. I think this is wrong and we should at least add upper bounds, however, I think that should be done in a separate PR to provide consistency.

Example:

json = [
    "smithy-json<=0.1.0"
]

Copy link
Contributor

Choose a reason for hiding this comment

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

I think that's a holdover from the previous build tool we were using which handled injecting versions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Interesting, I didn't know that was possible. Do you know that tool that was? I can look into if uv supports that feature.

@jonathan343 jonathan343 merged commit e5690f0 into develop Sep 17, 2025
6 checks passed
@jonathan343 jonathan343 deleted the fix-missing-deps branch September 17, 2025 17:44
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.

4 participants