Releases: smithy-lang/smithy-rs
January 12th, 2023
New this release:
- 🐛 (server, smithy-rs#2201) Fix severe bug where a router fails to deserialize percent-encoded query strings, reporting no operation match when there could be one. If your Smithy model uses an operation with a request URI spec containing query string literals, you are affected. This fix was released in
aws-smithy-http-server
v0.53.1.
January 11th, 2023
Breaking Changes:
- ⚠ (client, smithy-rs#2099) The Rust client codegen plugin is now called
rust-client-codegen
instead ofrust-codegen
. Be sure to update yoursmithy-build.json
files to refer to the correct plugin name. - ⚠ (client, smithy-rs#2099) Client codegen plugins need to define a service named
software.amazon.smithy.rust.codegen.client.smithy.customize.ClientCodegenDecorator
(this is the new file name for the plugin definition inresources/META-INF/services
). - ⚠ (server, smithy-rs#2099) Server codegen plugins need to define a service named
software.amazon.smithy.rust.codegen.server.smithy.customize.ServerCodegenDecorator
(this is the new file name for the plugin definition inresources/META-INF/services
).
New this release:
- 🐛 (server, smithy-rs#2103) In 0.52,
@length
-constrained collection shapes whose members are not constrained made the server code generator crash. This has been fixed. - (server, smithy-rs#1879) Servers support the
@default
trait: models can specify default values. Default values will be automatically supplied when not manually set. - (server, smithy-rs#2131) The constraint
@length
on non-streaming blob shapes is supported. - 🐛 (client, smithy-rs#2150) Fix bug where string default values were not supported for endpoint parameters
- 🐛 (all, smithy-rs#2170, aws-sdk-rust#706) Remove the webpki-roots feature from
hyper-rustls
- 🐛 (server, smithy-rs#2054) Servers can generate a unique request ID and use it in their handlers.
December 12th, 2022
Breaking Changes:
-
⚠🎉 (all, smithy-rs#1938, @jjantdev) Upgrade Rust MSRV to 1.62.1
-
⚠🎉 (server, smithy-rs#1199, smithy-rs#1342, smithy-rs#1401, smithy-rs#1998, smithy-rs#2005, smithy-rs#2028, smithy-rs#2034, smithy-rs#2036) Constraint traits in server SDKs are beginning to be supported. The following are now supported:
- The
length
trait onstring
shapes. - The
length
trait onmap
shapes. - The
length
trait onlist
shapes. - The
range
trait onbyte
shapes. - The
range
trait onshort
shapes. - The
range
trait oninteger
shapes. - The
range
trait onlong
shapes. - The
pattern
trait onstring
shapes.
Upon receiving a request that violates the modeled constraints, the server SDK will reject it with a message indicating why.
Unsupported (constraint trait, target shape) combinations will now fail at code generation time, whereas previously they were just ignored. This is a breaking change to raise awareness in service owners of their server SDKs behaving differently than what was modeled. To continue generating a server SDK with unsupported constraint traits, set
codegen.ignoreUnsupportedConstraints
totrue
in yoursmithy-build.json
.{ ... "rust-server-codegen": { ... "codegen": { "ignoreUnsupportedConstraints": true } } }
- The
-
⚠🎉 (server, smithy-rs#1342, smithy-rs#1119) Server SDKs now generate "constrained types" for constrained shapes. Constrained types are newtypes that encapsulate the modeled constraints. They constitute a widespread pattern to guarantee domain invariants and promote correctness in your business logic. So, for example, the model:
@length(min: 1, max: 69) string NiceString
will now render a
struct NiceString(String)
. Instantiating aNiceString
is a fallible operation:let data: String = ... ; let nice_string = NiceString::try_from(data).expect("data is not nice");
A failed attempt to instantiate a constrained type will yield a
ConstraintViolation
error type you may want to handle. This type's API is subject to change.Constrained types guarantee, by virtue of the type system, that your service's operation outputs adhere to the modeled constraints. To learn more about the motivation for constrained types and how they work, see the RFC.
If you'd like to opt-out of generating constrained types, you can set
codegen.publicConstrainedTypes
tofalse
. Note that if you do, the generated server SDK will still honor your operation input's modeled constraints upon receiving a request, but will not help you in writing business logic code that adheres to the constraints, and will not prevent you from returning responses containing operation outputs that violate said constraints.{ ... "rust-server-codegen": { ... "codegen": { "publicConstrainedTypes": false } } }
-
🐛⚠🎉 (server, smithy-rs#1714, smithy-rs#1342) Structure builders in server SDKs have undergone significant changes.
The API surface has been reduced. It is now simpler and closely follows what you would get when using the
derive_builder
crate:- Builders no longer have
set_*
methods taking inOption<T>
. You must use the unprefixed method, named exactly after the structure's field name, and taking in a value whose type matches exactly that of the structure's field. - Builders no longer have convenience methods to pass in an element for a field whose type is a vector or a map. You must pass in the entire contents of the collection up front.
- Builders no longer implement
PartialEq
.
Bug fixes:
- Builders now always fail to build if a value for a
required
member is not provided. Previously, builders were falling back to a default value (e.g.""
forString
s) for some shapes. This was a bug.
Additions:
- A structure
Structure
with builderBuilder
now implementsTryFrom<Builder> for Structure
orFrom<Builder> for Structure
, depending on whether the structure is constrained or not, respectively.
To illustrate how to migrate to the new API, consider the example model below.
structure Pokemon { @required name: String, @required description: String, @required evolvesTo: PokemonList } list PokemonList { member: Pokemon }
In the Rust code below, note the references calling out the changes described in the numbered list above.
Before:
let eevee_builder = Pokemon::builder() // (1) `set_description` takes in `Some<String>`. .set_description(Some("Su código genético es muy inestable. Puede evolucionar en diversas razas de Pokémon.".to_owned())) // (2) Convenience method to add one element to the `evolvesTo` list. .evolves_to(vaporeon) .evolves_to(jolteon) .evolves_to(flareon); // (3) Builder types can be compared. assert_ne!(eevee_builder, Pokemon::builder()); // (4) Builds fine even though we didn't provide a value for `name`, which is `required`! let _eevee = eevee_builder.build();
After:
let eevee_builder = Pokemon::builder() // (1) `set_description` no longer exists. Use `description`, which directly takes in `String`. .description("Su código genético es muy inestable. Puede evolucionar en diversas razas de Pokémon.".to_owned()) // (2) Convenience methods removed; provide the entire collection up front. .evolves_to(vec![vaporeon, jolteon, flareon]); // (3) Binary operation `==` cannot be applied to `pokemon::Builder`. // assert_ne!(eevee_builder, Pokemon::builder()); // (4) `required` member `name` was not set. // (5) Builder type can be fallibly converted to the structure using `TryFrom` or `TryInto`. let _error = Pokemon::try_from(eevee_builder).expect_err("name was not provided");
- Builders no longer have
-
⚠🎉 (server, smithy-rs#1620, smithy-rs#1666, smithy-rs#1731, smithy-rs#1736, smithy-rs#1753, smithy-rs#1738, smithy-rs#1782, smithy-rs#1829, smithy-rs#1837, smithy-rs#1891, smithy-rs#1840, smithy-rs#1844, smithy-rs#1858, smithy-rs#1930, smithy-rs#1999, smithy-rs#2003, smithy-rs#2008, smithy-rs#2010, smithy-rs#2019, smithy-rs#2020, smithy-rs#2021, smithy-rs#2038, smithy-rs#2039, smithy-rs#2041)
Plugins/New Service Builder API
The
Router
struct has been replaced by a newService
located at the root of the generated crate. Its name coincides with the same name as the Smithy service you are generating.use pokemon_service_server_sdk::PokemonService;
The new service builder infrastructure comes with a
Plugin
system which supports middleware onsmithy-rs
. See the mididleware documentation and the API documentation for more details.Usage of the new service builder API:
// Apply a sequence of plugins using `PluginPipeline`. let plugins = PluginPipeline::new() // Apply the `PrintPlugin`. // This is a dummy plugin...
October 24th, 2022
Breaking Changes:
- ⚠ (all, smithy-rs#1825) Bump MSRV to be 1.62.0.
- ⚠ (server, smithy-rs#1825) Bump pyo3 and pyo3-asyncio from 0.16.x to 0.17.0 for aws-smithy-http-server-python.
- ⚠ (client, smithy-rs#1811) Replace all usages of
AtomicU64
withAtomicUsize
to support 32bit targets. - ⚠ (server, smithy-rs#1803) Mark
operation
andoperation_handler
modules as private in the generated server crate.
Both modules did not contain any public types, therefore there should be no actual breakage when updating. - ⚠ (client, smithy-rs#1740, smithy-rs#256) A large list of breaking changes were made to accomodate default timeouts in the AWS SDK.
See the smithy-rs upgrade guide for a full list
of breaking changes and how to resolve them. - ⚠ (server, smithy-rs#1829) Remove
Protocol
enum, removing an obstruction to extending smithy to third-party protocols. - ⚠ (server, smithy-rs#1829) Convert the
protocol
argument onPyMiddlewares::new
constructor to a type parameter.
New this release:
- (server, smithy-rs#1811) Replace all usages of
AtomicU64
withAtomicUsize
to support 32bit targets. - 🐛 (all, smithy-rs#1802) Sensitive fields in errors now respect @sensitive trait and are properly redacted.
- (server, smithy-rs#1727, @GeneralSwiss) Pokémon Service example code now runs clippy during build.
- (server, smithy-rs#1734) Implement support for pure Python request middleware. Improve idiomatic logging support over tracing.
- 🐛 (client, aws-sdk-rust#620, smithy-rs#1748) Paginators now stop on encountering a duplicate token by default rather than panic. This behavior can be customized by toggling the
stop_on_duplicate_token
property on the paginator before callingsend
. - 🐛 (all, smithy-rs#1817, @ethyi) Update aws-types zeroize to flexible version to prevent downstream version conflicts.
- (all, smithy-rs#1852, @ogudavid) Enable local maven repo dependency override.
Contributors
Thank you for your contributions! ❤
- @GeneralSwiss (smithy-rs#1727)
- @ethyi (smithy-rs#1817)
- @ogudavid (smithy-rs#1852)
October 13th, 2022
There were issues with release automation for this release, and it has been yanked from crates.io.
Breaking Changes:
- ⚠ (client, smithy-rs#1811, @LukeMathWalker) Replace all usages of
AtomicU64
withAtomicUsize
to support 32bit targets. - ⚠ (server, smithy-rs#1803, @LukeMathWalker) Mark
operation
andoperation_handler
modules as private in the generated server crate.
Both modules did not contain any public types, therefore there should be no actual breakage when updating. - ⚠ (client, smithy-rs#1740, smithy-rs#256) A large list of breaking changes were made to accomodate default timeouts in the AWS SDK.
See the smithy-rs upgrade guide for a full list
of breaking changes and how to resolve them. - ⚠ (server, smithy-rs#1829) Remove
Protocol
enum, removing an obstruction to extending smithy to third-party protocols. - ⚠ (server, smithy-rs#1829) Convert the
protocol
argument onPyMiddlewares::new
constructor to a type parameter.
New this release:
- (server, smithy-rs#1811, @LukeMathWalker) Replace all usages of
AtomicU64
withAtomicUsize
to support 32bit targets. - 🐛 (all, smithy-rs#1802) Sensitive fields in errors now respect @sensitive trait and are properly redacted.
- (server, smithy-rs#1727, @GeneralSwiss) Pokémon Service example code now runs clippy during build.
- (server, smithy-rs#1734) Implement support for pure Python request middleware. Improve idiomatic logging support over tracing.
- 🐛 (client, aws-sdk-rust#620, smithy-rs#1748) Paginators now stop on encountering a duplicate token by default rather than panic. This behavior can be customized by toggling the
stop_on_duplicate_token
property on the paginator before callingsend
.
Contributors
Thank you for your contributions! ❤
September 20th, 2022
Breaking Changes:
- ⚠ (client, smithy-rs#1603, aws-sdk-rust#586)
aws_smithy_types::RetryConfig
no longer implementsDefault
, and itsnew
function has been replaced withstandard
. - ⚠ (client, smithy-rs#1603, aws-sdk-rust#586) Client creation now panics if retries or timeouts are enabled without an async sleep implementation.
If you're using the Tokio runtime and have thert-tokio
feature enabled (which is enabled by default),
then you shouldn't notice this change at all.
Otherwise, if using something other than Tokio as the async runtime, theAsyncSleep
trait must be implemented,
and that implementation given to the config builder via thesleep_impl
method. Alternatively, retry can be
explicitly turned off by settingmax_attempts
to 1, which will result in successful client creation without an
async sleep implementation. - ⚠ (client, smithy-rs#1603, aws-sdk-rust#586) The
default_async_sleep
method on theClient
builder has been removed. The default async sleep is
wired up by default if none is provided. - ⚠ (client, smithy-rs#976, smithy-rs#1710) Removed the need to generate operation output and retry aliases in codegen.
- ⚠ (client, smithy-rs#1715, smithy-rs#1717)
ClassifyResponse
was renamed toClassifyRetry
and is no longer implemented for the unit type. - ⚠ (client, smithy-rs#1715, smithy-rs#1717) The
with_retry_policy
andretry_policy
functions onaws_smithy_http::operation::Operation
have been
renamed towith_retry_classifier
andretry_classifier
respectively. Public memberretry_policy
on
aws_smithy_http::operation::Parts
has been renamed toretry_classifier
.
New this release:
-
🎉 (client, smithy-rs#1647, smithy-rs#1112) Implemented customizable operations per RFC-0017.
Before this change, modifying operations before sending them required using lower-level APIs:
let input = SomeOperationInput::builder().some_value(5).build()?; let operation = { let op = input.make_operation(&service_config).await?; let (request, response) = op.into_request_response(); let request = request.augment(|req, _props| { req.headers_mut().insert( HeaderName::from_static("x-some-header"), HeaderValue::from_static("some-value") ); Result::<_, Infallible>::Ok(req) })?; Operation::from_parts(request, response) }; let response = smithy_client.call(operation).await?;
Now, users may easily modify operations before sending with the
customize
method:let response = client.some_operation() .some_value(5) .customize() .await? .mutate_request(|mut req| { req.headers_mut().insert( HeaderName::from_static("x-some-header"), HeaderValue::from_static("some-value") ); }) .send() .await?;
-
(client, smithy-rs#1735, @vojtechkral) Lower log level of two info-level log messages.
-
(all, smithy-rs#1710) Added
writable
property toRustType
andRuntimeType
that returns them inWritable
form -
(all, smithy-rs#1680, @ogudavid) Smithy IDL v2 mixins are now supported
-
🐛 (client, smithy-rs#1715, smithy-rs#1717) Generated clients now retry transient errors without replacing the retry policy.
-
🐛 (all, smithy-rs#1725, @sugmanue) Correctly determine nullability of members in IDLv2 models
Contributors
Thank you for your contributions! ❤
- @ogudavid (smithy-rs#1680)
- @sugmanue (smithy-rs#1725)
- @vojtechkral (smithy-rs#1735)
August 31st, 2022
Breaking Changes:
-
⚠🎉 (client, smithy-rs#1598) Previously, the config customizations that added functionality related to retry configs, timeout configs, and the
async sleep impl were defined in the smithy codegen module but were being loaded in the AWS codegen module. They
have now been updated to be loaded during smithy codegen. The affected classes are all defined in the
software.amazon.smithy.rust.codegen.smithy.customizations
module of smithy codegen.` This change does not affect
the generated code.These classes have been removed:
RetryConfigDecorator
SleepImplDecorator
TimeoutConfigDecorator
These classes have been renamed:
RetryConfigProviderConfig
is nowRetryConfigProviderCustomization
PubUseRetryConfig
is nowPubUseRetryConfigGenerator
SleepImplProviderConfig
is nowSleepImplProviderCustomization
TimeoutConfigProviderConfig
is nowTimeoutConfigProviderCustomization
-
⚠🎉 (all, smithy-rs#1635, smithy-rs#1416, @weihanglo) Support granular control of specifying runtime crate versions.
For code generation, the field
runtimeConfig.version
in smithy-build.json has been removed.
The new fieldruntimeConfig.versions
is an object whose keys are runtime crate names (e.g.aws-smithy-http
),
and values are user-specified versions.If you previously set
version = "DEFAULT"
, the migration path is simple.
By settingversions
with an empty object or just not setting it at all,
the version number of the code generator will be used as the version for all runtime crates.If you specified a certain version such as
version = "0.47.0", you can migrate to a special reserved key
DEFAULT`.
The equivalent JSON config would look like:{ "runtimeConfig": { "versions": { "DEFAULT": "0.47.0" } } }
Then all runtime crates are set with version 0.47.0 by default unless overridden by specific crates. For example,
{ "runtimeConfig": { "versions": { "DEFAULT": "0.47.0", "aws-smithy-http": "0.47.1" } } }
implies that we're using
aws-smithy-http
0.47.1 specifically. For the rest of the crates, it will default to 0.47.0. -
⚠ (all, smithy-rs#1623, @ogudavid) Remove @sensitive trait tests which applied trait to member. The ability to mark members with @sensitive was removed in Smithy 1.22.
-
⚠ (server, smithy-rs#1544) Servers now allow requests' ACCEPT header values to be:
*/*
type/*
type/subtype
-
🐛⚠ (all, smithy-rs#1274) Lossy converters into integer types for
aws_smithy_types::Number
have been
removed. Lossy converters into floating point types for
aws_smithy_types::Number
have been suffixed with_lossy
. If you were
directly using the integer lossy converters, we recommend you use the safe
converters.
Before:fn f1(n: aws_smithy_types::Number) { let foo: f32 = n.to_f32(); // Lossy conversion! let bar: u32 = n.to_u32(); // Lossy conversion! }
After:
fn f1(n: aws_smithy_types::Number) { use std::convert::TryInto; // Unnecessary import if you're using Rust 2021 edition. let foo: f32 = n.try_into().expect("lossy conversion detected"); // Or handle the error instead of panicking. // You can still do lossy conversions, but only into floating point types. let foo: f32 = n.to_f32_lossy(); // To lossily convert into integer types, use an `as` cast directly. let bar: u32 = n as u32; // Lossy conversion! }
-
⚠ (all, smithy-rs#1699) Bump MSRV from 1.58.1 to 1.61.0 per our policy.
New this release:
-
🎉 (all, smithy-rs#1623, @ogudavid) Update Smithy dependency to 1.23.1. Models using version 2.0 of the IDL are now supported.
-
🎉 (server, smithy-rs#1551, @hugobast) There is a canonical and easier way to run smithy-rs on Lambda see example.
-
🐛 (all, smithy-rs#1623, @ogudavid) Fix detecting sensitive members through their target shape having the @sensitive trait applied.
-
(all, smithy-rs#1623, @ogudavid) Fix SetShape matching needing to occur before ListShape since it is now a subclass. Sets were deprecated in Smithy 1.22.
-
(all, smithy-rs#1623, @ogudavid) Fix Union shape test data having an invalid empty union. Break fixed from Smithy 1.21 to Smithy 1.22.
-
(all, smithy-rs#1612, @unexge) Add codegen version to generated package metadata
-
(client, aws-sdk-rust#609) It is now possible to exempt specific operations from XML body root checking. To do this, add the
AllowInvalidXmlRoot
trait to the output struct of the operation you want to exempt.
Contributors
Thank you for your contributions! ❤
- @hugobast (smithy-rs#1551)
- @ogudavid (smithy-rs#1623)
- @unexge (smithy-rs#1612)
- @weihanglo (smithy-rs#1416, smithy-rs#1635)
August 4th, 2022
Breaking Changes:
- ⚠🎉 (all, smithy-rs#1570, @weihanglo) Support @deprecated trait for aggregate shapes
- ⚠ (all, smithy-rs#1157) Rename EventStreamInput to EventStreamSender
- ⚠ (all, smithy-rs#1157) The type of streaming unions that contain errors is generated without those errors.
Errors in a streaming unionUnion
are generated as members of the typeUnionError
.
Taking Transcribe as an example, theAudioStream
streaming union generates, in the client, both theAudioStream
type:and its error type,pub enum AudioStream { AudioEvent(crate::model::AudioEvent), Unknown, }
pub struct AudioStreamError { /// Kind of error that occurred. pub kind: AudioStreamErrorKind, /// Additional metadata about the error, including error code, message, and request ID. pub(crate) meta: aws_smithy_types::Error, }
AudioStreamErrorKind
contains all error variants for the union.
Before, the generated code looked as:pub enum AudioStream { AudioEvent(crate::model::AudioEvent), ... all error variants, Unknown, }
- ⚠ (all, smithy-rs#1157)
aws_smithy_http::event_stream::EventStreamSender
andaws_smithy_http::event_stream::Receiver
are now generic over<T, E>
,
whereT
is a streaming union andE
the union's errors.
This means that event stream errors are now sent asErr
of the union's error type.
With this example model:Before:@streaming union Event { throttlingError: ThrottlingError } @error("client") structure ThrottlingError {}
After:stream! { yield Ok(Event::ThrottlingError ...) }
An example from the SDK is in transcribe streaming.stream! { yield Err(EventError::ThrottlingError ...) }
New this release:
- 🎉 (all, smithy-rs#1482) Update codegen to generate support for flexible checksums.
- (all, smithy-rs#1520) Add explicit cast during JSON deserialization in case of custom Symbol providers.
- (all, smithy-rs#1578, @lkts) Change detailed logs in CredentialsProviderChain from info to debug
- (all, smithy-rs#1573, smithy-rs#1569) Non-streaming struct members are now marked
#[doc(hidden)]
since they will be removed in the future
Contributors
Thank you for your contributions! ❤
July 20th, 2022
New this release:
- 🎉 (all, aws-sdk-rust#567) Updated the smithy client's retry behavior to allow for a configurable initial backoff. Previously, the initial backoff
(namedr
in the code) was set to 2 seconds. This is not an ideal default for services that expect clients to quickly
retry failed request attempts. Now, users can set quicker (or slower) backoffs according to their needs. - (all, smithy-rs#1263) Add checksum calculation and validation wrappers for HTTP bodies.
- (all, smithy-rs#1263)
aws_smithy_http::header::append_merge_header_maps
, a function for merging twoHeaderMap
s, is now public.
v0.45.0 (June 28th, 2022)
Breaking Changes:
- ⚠ (smithy-rs#932) Replaced use of
pin-project
with equivalentpin-project-lite
. For pinned enum tuple variants and tuple structs, this
change requires that we switch to using enum struct variants and regular structs. Most of the structs and enums that
were updated had only private fields/variants and so have the same public API. However, this change does affect the
public API ofaws_smithy_http_tower::map_request::MapRequestFuture<F, E>
. TheInner
andReady
variants contained a
single value. Each have been converted to struct variants and the inner value is now accessible by theinner
field
instead of the0
field.
New this release:
- 🎉 (smithy-rs#1411, smithy-rs#1167) Upgrade to Gradle 7. This change is not a breaking change, however, users of smithy-rs will need to switch to JDK 17
- 🐛 (smithy-rs#1505, @kiiadi) Fix issue with codegen on Windows where module names were incorrectly determined from filenames
Contributors
Thank you for your contributions! ❤