Skip to content

Closes #11152: Add support to abort custom script gracefully - #11621

Merged
jeremystretch merged 1 commit into
netbox-community:developfrom
BarbarossaTM:11152-report-script-errors
Feb 2, 2023
Merged

Closes #11152: Add support to abort custom script gracefully#11621
jeremystretch merged 1 commit into
netbox-community:developfrom
BarbarossaTM:11152-report-script-errors

Conversation

@BarbarossaTM

@BarbarossaTM BarbarossaTM commented Jan 30, 2023

Copy link
Copy Markdown
Contributor

Fixes: #11152

This PR adds a new AbortScript exception which a custom script can throw in case the script should be terminated cleanly. It allows specifying an error message which will be reported to the user, but no stack trace is shown. Any other unhandled exception will still raise a stacktrace.

@jeremystretch jeremystretch left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple very minor notes, but this is great work! Thank you!

Comment thread netbox/extras/scripts.py Outdated
Comment thread netbox/utilities/exceptions.py Outdated
Comment thread docs/customization/custom-scripts.md Outdated
Comment thread docs/customization/custom-scripts.md Outdated
@jeremystretch

Copy link
Copy Markdown
Member

@BarbarossaTM thanks for this! Do you think it would make sense to implement this functionality for reports too? (I'd be fine reusing the same AbortScript exception for reports.)

…cefully

Signed-off-by: Maximilian Wilhelm <max@sdn.clinic>
@BarbarossaTM
BarbarossaTM force-pushed the 11152-report-script-errors branch from ff2dd4a to 3c92787 Compare February 2, 2023 20:19
@jeremystretch
jeremystretch merged commit 699edd0 into netbox-community:develop Feb 2, 2023
@jeremystretch

Copy link
Copy Markdown
Member

Thanks @BarbarossaTM!

@BarbarossaTM
BarbarossaTM deleted the 11152-report-script-errors branch February 2, 2023 20:23
@BarbarossaTM

Copy link
Copy Markdown
Contributor Author

Thanks for the native speaker language polish :-)

I haven't used report myself yet, but I assume it might be useful there too, I guess the place to do it there would be in

def run_report(job_result, *args, **kwargs):

Do you want to me look into this and file another PR?

@jeremystretch

Copy link
Copy Markdown
Member

If you'd like to. Or we can wait and see if this gets any feedback first.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Mar 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow custom scripts to fail gracefully on errors detected by the scripts

2 participants