-
Notifications
You must be signed in to change notification settings - Fork 292
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
🪲 Don't crash the "view program" page if the program has a syntax error #5985
Conversation
It used to be that the "view program" page would crash if a program has syntax errors. The reason is that we try to translate programs from the language of the author to the language of the viewer, but that operation may fail due to parse errors, which aren't caught. In this PR I want to address a failure case as quickly as possible. There are some open issues/questions that someone else could/should have a look at later: - I have not written a test yet to make sure this doesn't re-occur. - We do translation in 2 steps: first to English, then to the target language. I don't know if that's on purpose or not; I imagine so, it's what the original code was doing and it must be for a reason. - The original code used to always normalize to English first, then translate to the target language. I've changed it to only translate if the source and target languages are different. - We have no way to surface the parse error the user. That may be fine because they can try running the program and then seeing the parse error, but just something to note.
Hello Rico, thanks for the PR.
I've just added a test for this case! Tried in main and it fails, and in this branch it succeeds.
We can't translate two arbitrary languages with each other, so we use English as a bridge, we can update the code, but I don't feel that's worth it right now.
I'm not aware of.
I think it's apparent that this program doesn't work, but indeed we are not letting the user know that there's a problem here. I think we can send a flag to the front end that the program contains an error and then show an alert somewhere. What do you think? |
If this is the case:
I think it's not worth it to invest time into. The error will show itself if the viewer clicks "Run program". |
cy.get('#editor > .cm-editor > .cm-scroller > .cm-content').click(); | ||
codeMirrorContent().click(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️
Thanks for the test! |
No worries, I'm actually just now seeing that we can translate any arbitrary languages indeed (I think we couldn't before, but may be I misremember) so I'm adapting that code as well. |
Lovely, thanks! Feel free to merge when you feel good about it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All good now!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dont add waits it’s never the answer
😭 I added a nice wait for an intercepted link and it's not working, so I'm debugging the issue! |
Thank you for contributing! Your pull request is now going on the merge train (choo choo! Do not click update from main anymore, and be sure to allow changes to be pushed to your fork). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dont merge until i figure out the test
Instead of a wait I added a timeout, still not the best, but a bit better I think! |
Thank you for contributing! Your pull request is now going on the merge train (choo choo! Do not click update from main anymore, and be sure to allow changes to be pushed to your fork). |
It used to be that the "view program" page would crash if a program has syntax errors. The reason is that we try to translate programs from the language of the author to the language of the viewer, but that operation may fail due to parse errors, which would cause the page to fail loading.
We used to only check for blanks and avoid translating a program because we knew that programs with blanks would fail to parse; but there are many more reasons that would case a parse failure, so instead of trying to predict them I'm now just catching the error.
In this PR I want to address a failure case as quickly as possible. There are some open issues/questions that someone else could/should have a look at later:
How to test
Write a syntactically invalid program and save it.
Use the
/hedy/.../view_program
link to view it, and observe that the page loads successfully.