Skip to content

Conversation

@drganjoo
Copy link
Contributor

@drganjoo drganjoo commented Nov 2, 2025

This commit introduces comprehensive http-1x support to the server code generator,
enabling generation of server SDKs that work with either [email protected] or [email protected]
based on the http-1x codegen flag.

Key Changes

New Infrastructure

  • HttpDependencies.kt: New data class that ensures cohesive HTTP dependency
    selection, preventing accidental mixing of HTTP 0.x and 1.x versions. Provides
    helper methods for accessing HTTP types (Request, Response, HeaderMap, etc.)

  • MultiVersionTestFailure.kt: Test infrastructure for tracking failures by
    HTTP version, enabling tests to run against both http@0 and http@1

ServerCodegenConfig Updates

  • Add http1x boolean field to control HTTP version selection (config key: http-1x)
  • Defaults to false ([email protected])

ServerCodegenContext Updates

  • Add isHttp1() method to check if http-1x is enabled
  • Add httpDependencies() method to provide version-appropriate HTTP dependencies
    throughout code generation

ServerRequiredCustomizations

  • Update to create and manage HttpDependencies based on http-1x setting
  • For http@0: use aws-smithy-legacy-http-server
  • For http@1: use aws-smithy-http-server

Protocol & Test Generator Updates

  • ServerProtocolTestGenerator: Support running protocol tests against both
    HTTP versions, with configurable test runtime mode (AS_CONFIGURED, BOTH, etc.)
  • ServerHttpBoundProtocolGenerator: Use HttpDependencies for all HTTP type
    references instead of hardcoded dependencies

Generator Updates

Updated generators to use HttpDependencies for type resolution:

  • ServerRootGenerator: Use httpDeps for dependency selection
  • ServerServiceGenerator: Pass HttpDependencies to child generators
  • ServerHttpSensitivityGenerator: Use httpDeps for HTTP types
  • ServerOperationGenerator, ServerBuilderGenerator: Use contextual HTTP deps

Test Infrastructure

  • ServerCodegenIntegrationTest: Add multi-version test support with
    ability to run tests against both HTTP versions
  • Http1xDependencyTest: New test validating correct dependency selection
    based on http-1x flag
  • Update existing tests to work with multi-version infrastructure

Core Changes

  • HttpBindingGenerator: Accept HttpDependencies parameter for version-appropriate
    type generation
  • EventStream generators: Use contextual HTTP dependencies
  • SmithyTypesPubUseExtra: Conditional imports based on HTTP version

Testing

All protocol tests can now run against both HTTP versions to ensure compatibility.
Tests track failures by HTTP version for easier debugging.

Relates to #3362

Fahad Zubair added 2 commits November 2, 2025 19:48
This commit introduces comprehensive http-1x support to the server code generator,
enabling generation of server SDKs that work with either [email protected] or [email protected]
based on the `http-1x` codegen flag.

## Key Changes

### New Infrastructure
- **HttpDependencies.kt**: New data class that ensures cohesive HTTP dependency
  selection, preventing accidental mixing of HTTP 0.x and 1.x versions. Provides
  helper methods for accessing HTTP types (Request, Response, HeaderMap, etc.)

- **MultiVersionTestFailure.kt**: Test infrastructure for tracking failures by
  HTTP version, enabling tests to run against both http@0 and http@1

### ServerRustSettings Updates
- Add `http1x` boolean flag to control HTTP version selection
- Add helper methods `isHttp0()` and `isHttp1()` for version checks

### ServerCodegenContext Updates
- Add `httpDependencies: HttpDependencies` property to provide version-appropriate
  HTTP dependencies throughout code generation

### ServerRequiredCustomizations
- Update to create and manage HttpDependencies based on http-1x setting
- For http@0: use aws-smithy-legacy-http-server
- For http@1: use [email protected]

### Protocol & Test Generator Updates
- **ServerProtocolTestGenerator**: Support running protocol tests against both
  HTTP versions, with configurable test runtime mode (AS_CONFIGURED, BOTH, etc.)
- **ServerHttpBoundProtocolGenerator**: Use HttpDependencies for all HTTP type
  references instead of hardcoded dependencies

### Generator Updates
Updated generators to use HttpDependencies for type resolution:
- ServerRootGenerator: Use httpDeps for dependency selection
- ServerServiceGenerator: Pass HttpDependencies to child generators
- ServerHttpSensitivityGenerator: Use httpDeps for HTTP types
- ServerOperationGenerator, ServerBuilderGenerator: Use contextual HTTP deps

### Test Infrastructure
- **ServerCodegenIntegrationTest**: Add multi-version test support with
  ability to run tests against both HTTP versions
- **Http1xDependencyTest**: New test validating correct dependency selection
  based on http-1x flag
- Update existing tests to work with multi-version infrastructure

### Core Changes
- HttpBindingGenerator: Accept HttpDependencies parameter for version-appropriate
  type generation
- EventStream generators: Use contextual HTTP dependencies
- SmithyTypesPubUseExtra: Conditional imports based on HTTP version

## Testing
All protocol tests can now run against both HTTP versions to ensure compatibility.
Tests track failures by HTTP version for easier debugging.

Related to http-1x migration effort and aws-smithy-http-legacy-server support.
@drganjoo drganjoo requested review from a team as code owners November 2, 2025 20:12
---
Add http-1x codegen support for server SDK generation

Enables generation of server SDKs compatible with either [email protected]/[email protected] or [email protected]/[email protected] based on the http-1x codegen flag.
Copy link
Collaborator

Choose a reason for hiding this comment

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

need more detail in the changelog message--e.g. changelog needs to say what the actual flag is, how to enable it etc.

Comment on lines 83 to 84
val httpDeps = HttpDependencies.create(settings.codegenConfig.http1x, rustSymbolProviderConfig.runtimeConfig)
EventStreamSymbolProvider(rustSymbolProviderConfig.runtimeConfig, it, CodegenTarget.SERVER, httpDeps.smithyHttp)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would recommend that we actually make RuntimeConfig "do the right thing". Or make it so that you MUST pass an http version setting when getting the dependencies that depend on it.

You could incorporate the http1x setting into RuntimeConfig potentially, then make things like smithyHttp http version aware?

I'm worried that the way the code works right now will be somewhat confusing for folks to deal with and create these really confusing compilation errors.

)
}
if (hasStreamingOperations(model, codegenContext.serviceShape)) {
println("[ServerRequiredCustomizations.pubUseSmithyPrimitivesHttp0x] Adding rt-tokio with http-body-0-4-x")
Copy link
Collaborator

Choose a reason for hiding this comment

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

did you want to leave these printlns?

class StatusCodeSensitivity(private val sensitive: Boolean, private val smithyHttpServer: RuntimeType) {
private val codegenScope =
arrayOf(
"SmithyHttpServer" to ServerCargoDependency.smithyHttpServer(runtimeConfig).toType(),
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should probably have ServerCargoDependency.smithyHttpServerAuto that automatically gives you the right one. I think the http version would actually fit pretty naturally into RuntimeConfig as an optional parameter.

Copy link
Collaborator

Choose a reason for hiding this comment

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

But if you just want to ship things like it is, I get that. I'm just kinda worried about the long term fallout of having it be non-centralized especially as we eventually try to get rid of the old codegen settings.

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