-
-
Notifications
You must be signed in to change notification settings - Fork 98
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
Traits break comparisons and calls for v3 and v2 #856
Comments
/progress 10 started to look into this... |
/progress 25 starting to get a hang of it and the different solutions, still need to figure out the best approach. |
Soo, this issue actually digs deeper than just on the surface... And the "problem" is different based on how you view the underlying implementation. Current behaviourWhen we apply the different "operations" such as parsing schemas, applying traits, anonymous naming, and handling circular references, we apply these things to two models
Even though these two are based on the same underlying in-memory object, the way the operations are applied, sometimes overwrites the entire object, meaning we will have a mismatch between the underlying data, where one gets the information and another wont. So when we in SolutionsThese are the solutions I can come up with, feel free to jump in with other approaches! Temporary fixWe could create a temporary fix JUST for solving the traits. One way to do this is to mark each object (probably channel, message, and operation) with unique IDs and then compare them instead of the entire JSON object. I don't have an overview, but if we have multiple places in the models where we compare the JSON structure of the two JSON variants, we might have more bugs somewhere. So I don't think that fully solves the underlying problem. Unifying the underlying JSONWe could unify the underlying JSON, meaning that the two properties don't differ at all. In theory that should work, without having to change the underlying models. However, I still think it's bad practice to compare entire JSON instead of simple unique ID's. Also, I don't know if it will work with circular references 🤔 Temporary + fix the underlying JSONWe could also combine the temporary with fixing the underlying JSON, as it's probably a better approach regardless 🤔 |
Do not take this as a proper answer. I need more time to refresh the whole workflow for parsing and applying custom ops, etc. Only then, I will come back and give you a better answer and hopefully help taking a decision. In one side, About the unique ID thing, I tried to find an old discussion we had somewhere in an issue where we discussed just a bit about that concept; to have that uid in all objects so we could compare. I would like to remember what were the caveats but I can't. I think @magicmatatjahu shared them as well 🤔 |
/progress 40 problem + potential solutions have been found, waiting on further feedback. |
/progress 50 started working on the implementation and adding tests to ensure it works long term |
Already fixed in #910 |
Describe the bug
I only have one concrete instance to show for here, but I bet it applies to other places as well.
How to Reproduce
With the following example https://github.com/asyncapi/spec/blob/next-major-spec/examples/streetlights-kafka.yml
And if you iterate over operations and want to find the associate channel for the operation:
It will always fail to find the channel if traits have been applied. The problem is the following line:
parser-js/src/models/v3/operation.ts
Line 52 in 1fa1240
An example would be,
channel
would hold the value:and
this._json.channel
would contain:Which should return true in comparison, however it will never happen because the underlying json are different because the parser applied traits, and in theory the extensions as well.
The text was updated successfully, but these errors were encountered: