CustomScript should not default to commit changes #2936

Closed
opened 2025-12-29 18:23:44 +01:00 by adam · 4 comments
Owner

Originally created by @Grokzen on GitHub (Oct 8, 2019).

Environment

  • Python version: 3.6.x
  • NetBox version: 2.6.5

Proposed Functionality

Right now the default in the ScriptForm for the commit option is to default to commit the changes on the script run. This sounds like a dangerous option. Change this to default to False in the form.

Use Case

This would prevent scripts form accidentally run and commit things that might not be the correct thing to run. Commiting changes through this feature should be Opt-in and not Opt-out.

Database Changes

External Dependencies

Originally created by @Grokzen on GitHub (Oct 8, 2019). <!-- NOTE: This form is only for proposing specific new features or enhancements. If you have a general idea or question, please post to our mailing list instead of opening an issue: https://groups.google.com/forum/#!forum/netbox-discuss NOTE: Due to an excessive backlog of feature requests, we are not currently accepting any proposals which significantly extend NetBox's feature scope. Please describe the environment in which you are running NetBox. Be sure that you are running an unmodified instance of the latest stable release before submitting a bug report. --> ### Environment * Python version: 3.6.x <!-- Example: 3.5.4 --> * NetBox version: 2.6.5 <!-- Example: 2.3.6 --> <!-- Describe in detail the new functionality you are proposing. Include any specific changes to work flows, data models, or the user interface. --> ### Proposed Functionality Right now the default in the `ScriptForm` for the commit option is to default to commit the changes on the script run. This sounds like a dangerous option. Change this to default to `False` in the form. <!-- Convey an example use case for your proposed feature. Write from the perspective of a NetBox user who would benefit from the proposed functionality and describe how. ---> ### Use Case This would prevent scripts form accidentally run and commit things that might not be the correct thing to run. Commiting changes through this feature should be Opt-in and not Opt-out. <!-- Note any changes to the database schema necessary to support the new feature. For example, does the proposal require adding a new model or field? (Not all new features require database changes.) ---> ### Database Changes <!-- List any new dependencies on external libraries or services that this new feature would introduce. For example, does the proposal require the installation of a new Python package? (Not all new features introduce new dependencies.) --> ### External Dependencies
adam added the status: acceptedtype: feature labels 2025-12-29 18:23:44 +01:00
adam closed this issue 2025-12-29 18:23:44 +01:00
Author
Owner

@jeremystretch commented on GitHub (Oct 8, 2019):

The current default makes sense to me. It's reasonable to assume that wanting a script to take effect is the more common use case than just experimenting with a script.

This would prevent scripts form accidentally run and commit things that might not be the correct thing to run.

Requiring the user to check a box won't significantly mitigate this risk.

@jeremystretch commented on GitHub (Oct 8, 2019): The current default makes sense to me. It's reasonable to assume that wanting a script to take effect is the more common use case than just experimenting with a script. > This would prevent scripts form accidentally run and commit things that might not be the correct thing to run. Requiring the user to check a box won't significantly mitigate this risk.
Author
Owner

@jeremystretch commented on GitHub (Oct 9, 2019):

How about an attribute on Script that allows the author to override the default behavior? Example:

class MyScript(Script):
    description = "Does something potentially dangerous"
    default_commit = False
@jeremystretch commented on GitHub (Oct 9, 2019): How about an attribute on Script that allows the author to override the default behavior? Example: ``` class MyScript(Script): description = "Does something potentially dangerous" default_commit = False ```
Author
Owner

@Grokzen commented on GitHub (Oct 9, 2019):

I do not agree with your argument that it is better to have commiting changes on by default and not even with a ConfirmForm in between. But, a flag to change it is better then not having it yes.

@Grokzen commented on GitHub (Oct 9, 2019): I do not agree with your argument that it is better to have commiting changes on by default and not even with a ConfirmForm in between. But, a flag to change it is better then not having it yes.
Author
Owner

@Grokzen commented on GitHub (Oct 9, 2019):

I can give a bit of a background as well, when we deployed the custom scripts and i made a few of them for the team to use, i did notice that almost everyone at least in the begining always wanted to run the script in dry-run mode first to see what really was going to happen and change. It is specially more usefull in the case where there is some random user that should use the script that either dont know the code by heart like i do that made it, or have run it plenty of times. After a while, yes some skipped to use it when they got comfortable with the specific script, but i did tell and try to teach the team that always to run dry-run first, look at the changes, inspect them and then commit them after you are satisifed with them, becuase once the script ir run, it can really damage more then you want and it is a pain to restore and revert some scripts that does a lot of complex changes to the data.

@Grokzen commented on GitHub (Oct 9, 2019): I can give a bit of a background as well, when we deployed the custom scripts and i made a few of them for the team to use, i did notice that almost everyone at least in the begining always wanted to run the script in dry-run mode first to see what really was going to happen and change. It is specially more usefull in the case where there is some random user that should use the script that either dont know the code by heart like i do that made it, or have run it plenty of times. After a while, yes some skipped to use it when they got comfortable with the specific script, but i did tell and try to teach the team that always to run dry-run first, look at the changes, inspect them and then commit them after you are satisifed with them, becuase once the script ir run, it can really damage more then you want and it is a pain to restore and revert some scripts that does a lot of complex changes to the data.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#2936