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

Missing "Run Script" button from Custom Scripts #16153

Closed
kollross opened this issue May 15, 2024 · 7 comments
Closed

Missing "Run Script" button from Custom Scripts #16153

kollross opened this issue May 15, 2024 · 7 comments
Assignees
Labels
status: revisions needed This issue requires additional information to be actionable type: bug A confirmed report of unexpected behavior in the application

Comments

@kollross
Copy link

Deployment Type

Self-hosted

NetBox Version

v4.0.2

Python Version

3.10

Steps to Reproduce

  1. Click on Customizations -> Scripts
  2. Can view script in the list (has edit, and delete buttons)
  3. No "Run Script option"

This script was working yesterday, I upgraded to 4.0.2 today and now that script is missing the button. Other scripts still have the "Run Script" option.

Expected Behavior

"Run Script" button be present and clickable.

Observed Behavior

emptyness

@kollross kollross added status: needs triage This issue is awaiting triage by a maintainer type: bug A confirmed report of unexpected behavior in the application labels May 15, 2024
@kollross kollross changed the title Missing "Run Script" from Custom Scripts Missing "Run Script" button from Custom Scripts May 15, 2024
@arthanson
Copy link
Collaborator

@kollross Thank you for opening a bug report. I was unable to reproduce the reported behavior on NetBox v4.0.2. "that script is missing the button." I don't know what that script is - the existing scripts I have on my installation still have the Run Script button. Can you please check what is different about the script then your other scripts, generally a run script button missing would indicate that there is an issue with the script code.

@arthanson arthanson added status: revisions needed This issue requires additional information to be actionable and removed status: needs triage This issue is awaiting triage by a maintainer labels May 15, 2024
@arthanson arthanson removed their assignment May 15, 2024
@bitcollector1
Copy link

I believe I have the same issue.

Screenshot 2024-05-15 at 15 39 27

What is worse is there is no way to delete the script now
Screenshot 2024-05-15 at 15 39 33

Screenshot 2024-05-15 at 15 39 38

@arthanson arthanson self-assigned this May 15, 2024
@arthanson
Copy link
Collaborator

@bitcollector1 "What is worse is there is no way to delete the script now" please file a separate issue if you are running into this and can reproduce.

@arthanson
Copy link
Collaborator

Note: There is a PR #15441 that adds better script error reporting (to show errors in the script code) - I'm guessing (without a repo scenario) that the scripts without the run button has an error, that PR would make it easier to find.

@bitcollector1
Copy link

bitcollector1 commented May 16, 2024

I was able to delete my script that had issues by going into the shell and deleting the event rule that was causing the issue deleting the problematic script

>>> EventRule.objects.all()
<RestrictedQuerySet [<EventRule: IP Updated>]>

>>> EventRule.objects.all().delete()
(2, {'extras.EventRule_object_types': 1, 'extras.EventRule': 1})
>>> 
>>> EventRule.objects.all().delete()
(0, {})

@bitcollector1
Copy link

bitcollector1 commented May 16, 2024

I can see my script now, it was in fact related to an error in the code that was preventing it from loading correctly.

Thanks you @arthanson very much for helping me see and fix my issue. This can get very tricky, with all the dependencies and changes going on :)

  1. Made change to existing code but had a syntax error
  2. Script then broke, but gave no real warning.....other than disappearing from GUI (I was using curl so did not see this)
  3. I was not able to delete the script due to the fact it was tied to the event rule
  4. I then had to go into nbshell to delete the event rule --> could not do it from GUI
  5. then I was able to delete the problem script
  6. finally able to reupload the new working script that had no errors.

@kollross
Copy link
Author

During the upgrade to 4.0.2 one of the required pip modules wasn't installed. But because I couldn't run the script from the GUI, there was no viable output to tell me it had a missing module. Deleting the script, and re-adding it produced a buttonless section of the script. Tailing the logs when deleting and re-adding the script also produced no errors. The only way I was able to troubleshoot to was to drop into /opt/netbox/venv/bin/python and running the script line by line to see where the erroring out.

Thank goodness for "#12813" otherwise this sort of thing would also impossible to troubleshoot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: revisions needed This issue requires additional information to be actionable type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
Development

No branches or pull requests

3 participants