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

Scriptrunner errors and can't recover if a try/except block exists in the python script #1929

Open
alex-pope1901 opened this issue Feb 28, 2025 · 0 comments · May be fixed by #1940
Open

Scriptrunner errors and can't recover if a try/except block exists in the python script #1929

alex-pope1901 opened this issue Feb 28, 2025 · 0 comments · May be fixed by #1940
Assignees
Labels
bug Something isn't working

Comments

@alex-pope1901
Copy link

Describe the bug
Scriptrunner provides a way to "GO", "RETRY", or "STOP" when an exception occurs in a script. This is especially helpful with timing dependent telemetry checks or when a script runs into a bad state. However, when a script contains a try/except block anywhere in the file, this feature does not work and scriptrunner will instead have an exception in the control and the only option is to stop the script. This behavior occurs as soon as a try except block has been passed (whether that's executing or just declaring a function with one in it.)

To Reproduce
Steps to reproduce the behavior:

  1. Go to Scriptrunner
  2. Create new python file with the following:
# Before try block this exception will be able to be passed with "GO"
raise Exception
def function_with_try_block():
  try:
    pass
  except Exception:
    pass
# After try block this exception will not be able to be passed with "GO"
raise Exception
  1. Save file and run the script
  2. First exception is raised and user is able to select "GO"
  3. Second exception is raised and user is unable to select "GO" or "RETRY," only "STOP" (additional error appears in the logs)

Expected behavior
Ideally the cosmos exception handling should be the default exception handler and additional try/except blocks should be added to the exception handling stack as they are entered. Raised exceptions should bubble up through this stack until one of try/excepts or ultimately cosmos handle it. For example:

# This will be handled by the cosmos exception handler
int("not an int")
# This will be handled by the explicit try/except in the script. 
try:
    int("not an int")
except ValueError:
    print("error")

Screenshots

Image
Script control options available with the first exception

Image
Script control options are not available after the function definition, and additional exception in control statement is displayed in logs.

Environment:

  • OS: Windows 11
  • OpenC3 COSMOS Version 6.1.0
  • Browser Firefox
@jmthomas jmthomas added the bug Something isn't working label Mar 4, 2025
@jmthomas jmthomas self-assigned this Mar 4, 2025
@jmthomas jmthomas linked a pull request Mar 5, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants