-
Notifications
You must be signed in to change notification settings - Fork 44
Data loss on invalidation of code in the editor #666
Comments
might be linked to #673 |
Prioritizing as 'Medium' instead of 'High' because this requires a bigger discussion about how the frontend should work with the backend to deal with invalid input. It could evolve into a larger discussion about state management, if we choose to maintain state of the code editor as separate from the visualization. |
So, we have three options here I think..
|
From my point of view:
In an ideal world, both canvas and source code always contain the same information, just in a different format. There are cases in which that doesn't happen. User is writing something incompleteThis happens when the code can be inferred, but the user hasn't completed it. For example, the user may want to add a twitter-search step:
They write that. And with that information, we all know what the apiVersion is going to be based on the step catalog. But, if you don't add it manually, this code is not deployable. And if you add it manually, you may be using an invalid apiVersion that is not the one deployed on the server. Kaoto, who knows what is behind the scenes, can add the apiVersion automatically to the source code:
Should the source code be auto-fixed and add the missing User is drafting codeThe user is half-writing something in the source code that is not yet clear what is going to be. For example a user editing a
which hints at a new step being added, but the name is not yet clear. On this case, true, the canvas can visualize some placeholder, but let's not focus on the solution to this specific case because there may be others. Just focus on the user writing something that is not yet clear what will be in the final form. But it is a valid YAML, it just needs some pieces.
While the user finishes writing, both canvas and source code cannot be synchronized. Should we leave that there in the source code? It won't be in the canvas, we have no way of adding that information there. But well, it is work in progress, we shouldn't remove it, right? User is writing nonsenseAnd then, the user may be writing something that really doesn't make sense and will never make sense but to them it is the final form.
What do we do with this? We can't really distinguish this from the previous case. We must treat both equally: either leaving them there or removing those pieces of code. |
So, from my perspective, the questions to solve this dilemma are: Do we want the canvas, the source code, or both to be the source of truth? If we decide the canvas is the source of truth:
If we decide the source code is the source of truth:
If we decide both are the source of truth: Same as before:
|
I can image leaving it as it is .. so both are source of truth but I'd disable auto fixing the source code or have a possibility to force fix. I'd focus on how tho actually visualise invalid source in reasonable way: If UI will send invalid source to the backend, backend will return invalid json instead of cleaned up, so for example step would have some additional state -valid/invalid or something. We would visualise also invalid code if yaml is valid, thanks to the steps having valid/invalid property we could actually guide the user which step is invalid. it could be displayed as temporary step or normal step -- depending on part that is invalid, for example if the name is valid but properties aren't it can be visualised as concrete step with some exclamation mark. We wouldn't allow deploying until code is valid. Even if we would allow, Kubernetes will return error anyway because AFAIK validation is happening there too. |
If you edit the canvas with that, the source code is replaced and you lose the invalid code. |
+1, disable once source code editor is open or show a warning dialog saying |
As I mentioned .. I can imagine to visualise also invalid code to some extend so it wouldn't be removed necessary. Because only time where the code has to be valid and functional is right before deployment/export. So allowing users to fix the invalid code in visual way could be cool. |
Note that the invalid code will not be on the visual side. If it was there, it won't be invalid :) |
I understand it would be great if we can show the broken code in some way in canvas as well (maybe with an icon of a broken bin), but it would need a custom compiler/parser and handle line by line. I don't think it pays at this earlier stage. |
Given all the discussions, it seems to me that:
Consequently, I see 2 main steps:
For the "relatively short time" to implement, I think the solution mentioned about disabling the canvas when there is a not completely parseable and managed yaml file is the one that fit the most. |
My proposed solution for this issue:
And on subsequent iterations we will work in improving the source code with features like (not limited to):
|
My solution would be similar but:
|
Do we disable the canvas while editing the source code? What if it is valid but incomplete code? How are we going to implement that validation? Comparing the input and output of the text blob that comes from the backend? |
So I'm expecting that validation is done in the backend side. I'm imagining having the response of the integration endpoint like:
I wouldn't compare the code because valid code still can be formatted or something and might differ. I don't know how validation is done on the backend side so if this is something that is hard to do in our current time frame I'm fine with your solution too. |
So, that's the thing, there is no validation. We just marshal the yaml into java objects. So if we are going to add some validation status, we will need to implement that. Plus, the idea of returning
is not appealing to me because we are mixing there different media types (the source code media type and json) |
PR: #972 |
Describe the bug
If you create a flow in the graphical editor and then switch to the code editor and make one line in the yaml invalid, parts of the code disappear as well as the corresponding figure(s) on the canvas.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Allow invalid code while being at design time. Just trashing invalid code makes the UX really bad.
Screenshots
The text was updated successfully, but these errors were encountered: