smithy-lang / smithy

Smithy is a protocol-agnostic interface definition language and set of tools for generating clients, servers, and documentation for any programming language.
https://smithy.io
Apache License 2.0
1.7k stars 201 forks source link

Fix ModifiedTrait for traits with breaking change rules #2249

Closed syall closed 2 months ago

syall commented 2 months ago

Overview

Fix ModifiedTrait for traits with breaking change rules.

Before this change, if a trait had breaking change rules defined, the diff strategy in ModifiedTrait would eventually resolve the trait as unknown and produce a ModifiedTrait warning on any change.

Also, apply @tags(["diff.contents"]) to a structure member of the "all" ModifiedTrait test, which is a no-op.

Testing

Tested with @jsonName:

Model A:

$version: "2.0"

namespace ns.foo

structure Test {
    @jsonName("a")
    member: String
}

Model B:

$version: "2.0"

namespace ns.foo

structure Test {
    @jsonName("b")
    member: String
}

Diff events before the change (see duplicate ModifiedTrait event):

[ERROR] ns.foo#Test$member: Changed trait `smithy.api#jsonName` from `a` to `b` | TraitBreakingChange.Update.smithy.api#jsonName
[WARNING] ns.foo#Test$member: Changed trait `smithy.api#jsonName` from `a` to `b` | ModifiedTrait.Update.smithy.api#jsonName

Diff events after the change (no duplicate ModifiedTrait event):

[ERROR] ns.foo#Test$member: Changed trait `smithy.api#jsonName` from `a` to `b` | TraitBreakingChange.Update.smithy.api#jsonName

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.