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

Bug: Saving models in text mode with import statement will break the project on next load #2446

Open
1 of 8 tasks
akphi opened this issue Jul 21, 2023 · 0 comments
Open
1 of 8 tasks
Labels
Component: Text Mode Studio Core Team Opened by a member of the Studio core team Type: Bug Type: Regression A bug that did not exist in previous versions
Milestone

Comments

@akphi
Copy link
Contributor

akphi commented Jul 21, 2023

Similar issues

  • I have searched and found no existing similar issues

How are you using Studio?

Legend Studio

Current and expected behavior

A while ago, we removed graph building from text mode, users now can save their changes directly from text mode, but due to this, sometimes, they could accidentally save text of models which depends on import statement to fully resolve paths; this is bad since we skip SectionIndex when persisting to SDLC. Previously, when we still build the graph in text-mode, the diff algo will make use of graph builder to fully resolve all the paths before saving, this is no-longer the case.

Steps to reproduce

Copy and paste the following provided text in text-mode and save, the next load the project will be broken and users will be asked to return to text-mode.

Model data

import model::*;

Class model::A {}
Class model::B extends A {}

Environment

No response

Possible solution and workaround

The possible solution is to enforce path resolution before saving in text-mode so we save entities with all paths resolved, i.e. rid ourselves of the responsibility to save import statements. I think we can follow the steps below in terms of mechanic and interaction:

  • When the users click save in text mode, first, we parse the grammar to obtain the graph data
  • If there is no section (in SectionIndex) with imports, we proceed with save per normal
  • Otherwise, we alert the users (using ActionAlert): "Import statements will not be saved, we can attempt to automatically resolve the full paths, or you can manually resolve them, remove the import statements, and try saving again" Have 2 actions: "Resolve automatically", "Resolve manually"
  • If they choose Resolve Manually nothing to be done, just close the ActionAlert
  • Otherwise, we proceed with building the graph like what we would do when switching from text-mode to form-mode and then compute the new changeset and attempt to save - while doing this, add a BlockingAlert to prevent users from making any changes/actions that might interfere with the process
  • NOTE: if at any point, the process fails, we will warn the user, "Can't automatically resolve the full paths. Please manually resolve them, remove the import statements, and try saving again". The only action here is "Resolve manually"

Contribution

  • I would like to work on the fix for this issue
@akphi akphi added Type: Bug Type: Regression A bug that did not exist in previous versions Component: Text Mode labels Jul 21, 2023
@akphi akphi added this to the 11.0.0 milestone Jul 21, 2023
@github-actions github-actions bot added the Studio Core Team Opened by a member of the Studio core team label Jul 21, 2023
@github-actions github-actions bot modified the milestones: 11.0.0, 12.0.0 Dec 21, 2023
@github-actions github-actions bot modified the milestones: 12.0.0, 13.0.0 Jul 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Text Mode Studio Core Team Opened by a member of the Studio core team Type: Bug Type: Regression A bug that did not exist in previous versions
Projects
None yet
Development

No branches or pull requests

1 participant