Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Required trait removal doesn't emit any events - should it? #1744

Closed
kubukoz opened this issue Apr 20, 2023 · 2 comments · Fixed by #1895
Closed

Required trait removal doesn't emit any events - should it? #1744

kubukoz opened this issue Apr 20, 2023 · 2 comments · Fixed by #1895
Labels
investigating This issue is being investigated and/or work is in progress to resolve the issue.

Comments

@kubukoz
Copy link
Contributor

kubukoz commented Apr 20, 2023

Hi!

I bumped into this: if you merge two models with a member that's @required in one but not in the other, the merged model will always make the field required.

While this behavior is consistent with the usual handling of traits in model merging, shouldn't this emit some sort of event, whether it be a NOTE or WARN? I imagine some code might misbehave if you merge things like these:

structure Greeting {
  from: String,
  @required to: String
}
structure Greeting {
  @required from: String,
  to: String
}
@kubukoz kubukoz changed the title Required trait removal doesn't emit any events Required trait removal doesn't emit any events - should it? Apr 20, 2023
@mtdowling
Copy link
Member

The title of the issue seems off here right? The required trait isn't removed, it's merged into the resulting member and kept. There's a warning logged for the Greeting shape, but nothing about the member. This warning is only logged when the conflict is allowed:

WARNING: Ignoring duplicate but equivalent shape definition: example#Greeting defined at b.smithy [3, 1] and a.smithy [3, 1]

I'm not sure that we can detect trait deltas between two merged members. When model files are loaded, shapes are essentially broken into pieces and later reassembled with the merging process. In a way, all traits applied to shapes/members basically become apply statements. When Greeting from model B is loaded, there's no notion of a fully formed shape or members with traits from model A's Greeting shape to compare against.

Maybe we could turn that logged warning into a validation event, to bring more attention to this.

@kubukoz
Copy link
Contributor Author

kubukoz commented Apr 20, 2023

The required trait isn't removed, it's merged into the resulting member and kept.

Right, what I mean is that I removed it between model versions and it still ends up in the final model once the old and new version are merged :)

@kstich kstich added the investigating This issue is being investigated and/or work is in progress to resolve the issue. label Jul 24, 2023
mtdowling added a commit that referenced this issue Aug 1, 2023
mtdowling added a commit that referenced this issue Aug 1, 2023
syall pushed a commit to Xtansia/smithy that referenced this issue Aug 11, 2023
alextwoods pushed a commit to alextwoods/smithy that referenced this issue Sep 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
investigating This issue is being investigated and/or work is in progress to resolve the issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants