Skip to content

docs: add the diff standard #9

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

Closed
wants to merge 6 commits into from

Conversation

aayushmau5
Copy link
Member

@aayushmau5 aayushmau5 commented Jul 1, 2021

In order to categorize a certain change to AsyncAPI document as "breaking" or "non-breaking", we need to have a "standard" which documents what changes can be considered "breaking" or "non-breaking".

When the community agrees on this "standard", it will be mapped to a JSON file which will contain all the information in here, which the diff library can utilize to categorize changes.

Please note that the standard has been written from the Point of View of a Consumer(client/server), thus some changes were considered as "non-breaking" because the consumer won't be affected by that change.

Copy link
Member

@derberg derberg left a comment

Choose a reason for hiding this comment

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

Awesome stuff!
Very good take on taking the user perspective here imho.

For better review, could you please introduce another section where you group all breaking and non breaking changes. So reviewer instead of going through all props to see what is breaing, can actually just check out all breaking props in one group? I mean:

## Breaking changes

- Change in `version` in `info`
- Change in `url` in `server`
- `Server` object removal

Also please clearly state in the intro that atm bindings are out of scope for diff library as these are yet not mature enough and lack proper tooling support

@MikeRalphson
Copy link

When the community agrees on this "standard", it will be mapped to a JSON file which will contain all the information in here, which the diff library can utilize to categorize changes.

I love the idea of a machine-readable diff-map which can be applied to a target document. Thus (if there was a JSON Schema for the diff-map object) we could create one for other JSON/YAML based standards (cough) not just AsyncAPI.

My only query would be about treating a change in $ref automatically as a breaking change. Possibly the diff should run over a de-referenced input file? Thus converting a direct object into a $ref or vice-versa would itself not be treated as a change at all.

Copy link
Member

@jonaslagoni jonaslagoni left a comment

Choose a reason for hiding this comment

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

Looking good @aayushmau5 👏

I would love if the document defines the thought behind when a change is considered non-breaking vs breaking.

For example, any change to id might not be considered a breaking change in general (again depending on the thought behind the diff), but it depends on the use case. If a user uses the id to generate specific code that suddenly breaks because for that user id IS a breaking change.

As @MikeRalphson touched upon, I suggest that, while we define a standard diff, it should be adaptable and modified by the user, which means instead of hardcoding/forcing what is breaking and what is not, maybe it can be done using a configuration? At least consider whether it would be worth investing in from the start, maybe it won't be that difficult compared to hardcoding it.

I completely agree with @MikeRalphson that changes to $ref cannot on its own be considered a breaking change. It needs to be realized first.

standard.md Outdated
1. Change in `traits` in `subscribe`|`publish`
1. Change in `contentType` in `message`
1. Change in `name` in `message`
1. Change in `payload` in `message`
Copy link
Member

Choose a reason for hiding this comment

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

To me this cannot be stated, what if you change the description of a property when using JSON Schema? 🤔 That should not be considered a breaking change.

What's the reason behind assuming changes to payload is breaking?

I could see that this is just for more easily assume it, as you then would need to diff JSON Schema as well, which is gonna take more time 😅

Copy link
Member Author

@aayushmau5 aayushmau5 Jul 5, 2021

Choose a reason for hiding this comment

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

I completely overlooked that point, but you are right, changing the description and such in message payload(inside a JSON schema) is not a breaking change. Will update the document :)

Copy link
Member

Choose a reason for hiding this comment

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

I think we could try to define a basic minimum of non-breaking changes in JSON Schema in payload and threat the rest as breaking, or? later it could evolve into something separate? or we are complete excluding payload content from Diff because AsyncAPI allows also payloads with Avro and other formats? This way we would always treat change in payload as breaking, clearly documented and explained of course

Copy link
Member Author

Choose a reason for hiding this comment

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

I think we could try to define a basic minimum of non-breaking changes in JSON Schema in payload and threat the rest as breaking, or?

I thought about this. Like, we can define a set of properties as non-breaking and mark others as breaking. But I'm not too sure if we should do that or not.

we are complete excluding payload content from Diff because AsyncAPI allows also payloads with Avro and other formats?

I don't think so. Like @jonaslagoni said, changing the description will throw us a "breaking" change error where it is not.

But then again, do we want to go through the whole JSON Schema and mark everything as breaking/non-breaking?
If that's the case, we can go with the first approach. Only put "non-breaking" properties in the standard, and treat everything else as "breaking"

Copy link
Member

Choose a reason for hiding this comment

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

both solutions are bad and not something user can rely on. Wouldn't it make sense to have 3rd category like, uncategorized? or unknown?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I think having an unknown or uncategorized category will be good.

So, what message do you think should uncategorized convey? I'm thinking of something like "these changes are uncategorized, the user should handle these themselves".

Copy link
Member Author

Choose a reason for hiding this comment

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

So, I have made some changes to the standard. Now it includes unclassfied changes as well. Right now, the message headers and payload are being marked as unclassified.

@ponelat
Copy link

ponelat commented Jul 2, 2021

When the community agrees on this "standard", it will be mapped to a JSON file which will contain all the information in here, which the diff library can utilize to categorize changes.

I love the idea of a machine-readable diff-map which can be applied to a target document. Thus (if there was a JSON Schema for the diff-map object) we could create one for other JSON/YAML based standards (cough) not just AsyncAPI.

My only query would be about treating a change in $ref automatically as a breaking change. Possibly the diff should run over a de-referenced input file? Thus converting a direct object into a $ref or vice-versa would itself not be treated as a change at all.

My 2c on whether $refs are breaking changes... ideally I'd like to see both, something indicating that the $ref is broken, and something indicating that all those things that reference are naturally broken. This prompt is based on how validation that occurs on the resolved spec can be noisy as hell. As well as the fact that the breaking change may being address/fixed in one place, not many -- both in code (if the $ref'd model is reusable) and in the definition. </2c>

@aayushmau5
Copy link
Member Author

aayushmau5 commented Jul 5, 2021

I would love if the document defines the thought behind when a change is considered non-breaking vs breaking.

@jonaslagoni Working on it :)

For example, any change to id might not be considered a breaking change in general (again depending on the thought behind the diff), but it depends on the use case. If a user uses the id to generate specific code that suddenly breaks because for that user id IS a breaking change.

Interesting. You are right, it might depend on the use case whether a change in breaking or not.

As @MikeRalphson touched upon, I suggest that, while we define a standard diff, it should be adaptable and modified by the user, which means instead of hardcoding/forcing what is breaking and what is not, maybe it can be done using a configuration? At least consider whether it would be worth investing in from the start, maybe it won't be that difficult compared to hardcoding it.

I really like this idea. I'm thinking of having some defaults configs that come with the package, but it can be easily overridable. So, In case if someone doesn't like the default configs, they can provide their own config, which our diff will use instead of using the default one. Any thoughts?

I completely agree with @MikeRalphson that changes to $ref cannot on its own be considered a breaking change. It needs to be realized first.

Yup, I think you are right. The parser will inline those $refs, so i think changing the value of $ref should not be considered a breaking change.

Copy link
Member

@derberg derberg left a comment

Choose a reason for hiding this comment

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

did you already think on how this standard would be coded?
did you consider that what you have here could be later declared in a yml file that user can override as a config?

example yaml file would have info.license on a list with a description that it is breaking because the license of the API changed that needs to be reviewed before the user uses the API further. It would be marked as breaking. But user would be able to provide alternative yaml where this is marked as non-breaking

@aayushmau5
Copy link
Member Author

did you already think on how this standard would be coded?
did you consider that what you have here could be later declared in a yml file that user can override as a config?

Kind of. Will need to discuss on that as well, but right now, as a POC, I have a standard.json file which has this key:value pair. Like "asyncapi": { "type":"breaking" }, but Like I said, nothing is set right now. We will need to discuss on that.

So, if a user provides a json or yml(which we can convert to json), we will merge that change into the JSON using some JSON merging technique.

@derberg
Copy link
Member

derberg commented Jul 7, 2021

@aayushmau5 yup, a definitely separate topic, good for another GitHub Issue 😄 and something that can be added later, which will be easy if you already take config from a json

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

Copy link
Collaborator

@vinitshahdeo vinitshahdeo left a comment

Choose a reason for hiding this comment

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

@aayushmau5 Can you please also talk about how are we going to present these changes to the user?

@aayushmau5
Copy link
Member Author

aayushmau5 commented Jul 27, 2021

Hey @vinitshahdeo There's an ongoing discussion about the output in this issue: #14

Definitely need your input there :)

@derberg
Copy link
Member

derberg commented Aug 17, 2021

@aayushmau5 what plans do you have with this PR?

@aayushmau5
Copy link
Member Author

aayushmau5 commented Aug 17, 2021

@derberg I was thinking about this, and I'm not too sure what to do with this document. If we only care about the categories of changes, one can see them inside our standard object.

I guess we can use this document to justify why a change has been considered breaking, non-breaking etc. What do you say?

@derberg
Copy link
Member

derberg commented Aug 18, 2021

for sure useful part is how we classify changes and why but rest is redundant with the standard I think. Maybe just move some of it to readme and that is it, and in the readme link to standard after initial explanation

@aayushmau5
Copy link
Member Author

Closing this one. Main points that should be addressed will be addressed in the README.

@aayushmau5 aayushmau5 closed this Aug 20, 2021
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.

6 participants