Handle null table in TableConfigForm #18728
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes: #18722
This simple defensive fix ensures that
tableis not null before trying to initialize the fields on it. This handles the case where a custom script fails due to an error, resulting in anAttributeError: 'NoneType' object has no attribute 'available_columns'on the ephemeral job result page (http://127.0.0.1:8000/extras/scripts/results/33/) which only appears after directly running the script via the UI.Normally NetBox will validate any syntax errors or other issues with a newly uploaded script and prevent it from being runnable. However, if an existing script fails to run due to an emergent systemic issue, the result page will throw the above error because
table(which would show log results) is null. With this fix, the table is simply omitted and the "Errored" badge is shown. The specifics of the error can then be seen in the job detail page (http://127.0.0.1:8000/core/jobs/14/).