Skip to content
Snippets Groups Projects
Select Git revision
  • release-2025-05-15-with-patches protected
  • main default protected
  • release-2025-03-27-with-patches protected
  • release-2024-12-30-with-client-builder protected
  • release-2024-12-26-with-client-builder protected
  • release-2024-11-05-with-client-builder protected
  • release-2024-08-16-with-client-builder protected
  • release-2024-09-09-with-client-builder protected
  • release-2024-08-28-with-client-builder protected
  • release-2024-10-09-with-client-builder protected
  • sbuttgereit/expose_client_builder_with_hyper_1_0
  • release-2025-05-15
  • release-2025-05-09
  • release-2025-05-02
  • release-2025-04-23
  • release-2025-03-27
  • release-2025-03-25
  • release-2025-03-10
  • release-2025-03-04
  • release-2025-02-20
  • release-2025-02-12
  • release-2025-02-03
  • release-2025-01-28
  • release-2025-01-23
  • release-2025-01-17
  • release-2025-01-14
  • release-2024-12-30
  • release-2024-12-26
  • release-2024-12-16
  • release-2024-12-03
  • release-2024-11-05
31 results

smithy-rs

  • Clone with SSH
  • Clone with HTTPS
  • user avatar
    ysaito1001 authored
    ## Description
    This PR fixes a regression in input serializers. Previously, fields of
    numbers/bool annotated with the `required` trait were always serialized.
    With the introduction of the
    [addedDefault](https://smithy.io/2.0/spec/type-refinement-traits.html#addeddefault-trait)
    trait, they stopped being serialized when an input values match the
    default even if explicitly set by the user.
    
    An example is `LoggingConfig` in CloudFront
    ([change](https://github.com/awslabs/aws-sdk-rust/commit/3465444a0f6b66816febdeb6441110ec283c1317#diff-8ff83311bcd0649ac0bee175e8a1f3d1fce9c8863c64b896c58f41ac17051bf0R8)).
    The previously required fields `enabled` and `include_cookies` were
    annotated with the `addedDefault` trait and the `LoggingConfig`'s
    serializer made serialization of those fields conditional:
    ```
    pub fn ser_logging_config(...) -> ... {
        #[allow(unused_mut)]
        let mut scope = writer.finish();
        if input.enabled {
            let mut inner_writer = scope.start_el("Enabled").finish();
            inner_writer.data(::aws_smithy_types::primitive::Encoder::from(input.enabled).encode());
        }
        if input.include_cookies {
            let mut inner_writer = scope.start_el("IncludeCookies").finish();
            inner_writer.data(::aws_smithy_types::primitive::Encoder::from(input.include_cookies).encode());
        }
       ...
    ``` 
    When their values were `false`, they did not get serialized, regardless
    of whether they were explicitly set; when they were `required` fields
    previously, they had always been serialized.
    
    This has caused CloudFront SDK users to encounter an error response from
    the service, e.g,
    ```
    You must specify IncludeCookies when Enabled is missing or set to true within a Logging object
    ``` 
    
    This PR treats the `addedDefault` trait as non `default`, making the
    fields always be serialized.
    
    ## Testing
    - CI and release pipeline
    - Confirmed that `LoggingConfig`'s serializer always serializes the
    fields in question
    
    ## Checklist
    <!--- If a checkbox below is not applicable, then please DELETE it
    rather than leaving it unchecked -->
    - [x] For changes to the smithy-rs codegen or runtime crates, I have
    created a changelog entry Markdown file in the `.changelog` directory,
    specifying "client," "server," or both in the `applies_to` key.
    - [x] For changes to the AWS SDK, generated SDK code, or SDK runtime
    crates, I have created a changelog entry Markdown file in the
    `.changelog` directory, specifying "aws-sdk-rust" in the `applies_to`
    key.
    
    ----
    
    _By submitting this pull request, I confirm that you can use, modify,
    copy, and redistribute this contribution, under the terms of your
    choice._
    84f5464a
    History
    Name Last commit Last update