Commit Graph

15851 Commits

Author SHA1 Message Date
bctiemann bc879dc48f
Merge pull request #22900 from netbox-community/22896-merge-main-into-feature
Merge main to feature
2026-08-10 20:32:09 -04:00
Jeremy Stretch b1d1919db3 Ensure a consistent error structure for both single and bulk requests 2026-08-10 16:33:25 -04:00
Jeremy Stretch 7de5a62451 Flag duplicate object IDs in bulk operations 2026-08-10 16:15:55 -04:00
Brian Tiemann fde10cbf22 Merge branch 'feature' into 22896-merge-main-into-feature
Resolves all conflicts between main and feature for #22896. Notable
resolutions:

- dcim/signals.py, dcim/tests/test_signals.py: main's cache_presave_scope_fields
  / sync_cached_scope_fields addition is fully superseded by feature's
  PostgreSQL-trigger-based denormalization (confirmed via feature's own
  migration docstrings); dropped in favor of feature's existing approach.
  Both files now match feature's originals exactly.

- netbox/tables/columns.py: combined main's generic get_ordering_annotation()
  protocol with feature's nulls_first-aware order() override. These two
  mechanisms cannot both apply to the same column (django-tables2 negates an
  entire order_by tuple uniformly on direction toggle, so a fixed nulls_first
  placement and multi-column sort composition are mutually exclusive for one
  column) -- preserved nulls_first (existing, wired through forms/API/GraphQL)
  and removed main's two composition-only tests for CustomFieldColumn. See the
  comment on CustomFieldColumn.order() for full reasoning.

- extras/customfields.py, extras/graphql/mixins.py: combined main's
  request-cache optimization and has_key-scoped batch updates with feature's
  resolve_selection_value() (shared select-field label resolution between
  REST and GraphQL).

- extras/events.py, extras/event_rules.py: main's "Honor Script defaults when
  triggered by Event Rules" (#22852) fix was written against the old inline
  action-type dispatch, which feature had already replaced with a pluggable
  action-provider registry (#22770). Re-applied the same two-line fix
  (notifications/job_timeout) inside ScriptAction.enqueue() in event_rules.py
  instead.

- utilities/jinja2.py: fixed a config-attribute name mismatch the raw merge
  would have introduced (main's JINJA2_FILTERS vs feature's renamed
  JINJA_FILTERS) by updating the shared _jinja2_filters() helper.

- ipam/migrations/: renumbered main's 0094_ipaddress_host_index to 0096 and
  added a merge migration, since main and feature had each independently
  added a migration numbered 0094.

- dcim/tests/query_counts.json: regenerated via UPDATE_QUERY_COUNTS=1 against
  the merged codebase rather than hand-merging counts.

Verified: manage.py check clean, full migration graph applies cleanly from
scratch, ruff clean, and full test suites pass for dcim, ipam, netbox, extras,
circuits, vpn, wireless, tenancy, virtualization, core, users, and account
(fresh databases, no state carried over between runs).
2026-08-10 16:13:01 -04:00
Jeremy Stretch e6dfad94c5 Move sequential creation behavior into BulkCreateModelMixin to ensure consistent error reports 2026-08-10 15:55:00 -04:00
Jeremy Stretch f68c4f63a7 Handle AbortRequest to ensure error details are returned 2026-08-10 15:22:18 -04:00
Jeremy Stretch e17227d67d Raise error when attempting to update/delete objects by unknown ID 2026-08-10 14:58:20 -04:00
Jeremy Stretch 02a350dc67 Clear events queue on rollback (single and bulk changes) 2026-08-10 14:18:16 -04:00
bctiemann ae8fa4c074
Merge pull request #22870 from netbox-community/22852-scripts-run-from-event-rules-ignore-notifications_default
Fixes #22852: Honor Custom Script execution defaults for Event Rules and `runscript`
2026-08-10 14:02:25 -04:00
Jeremy Stretch a4dcd82606
Fixes #22894: Sanitize error message rendered during exception in CustomLinkColumn (#22895) 2026-08-10 19:47:36 +02:00
Graham fca786bdf2
Closes #22502: Add direct unit tests for is_api_request() and is_graphql_request() (#22880) 2026-08-10 09:56:44 -05:00
Jeremy Stretch d76340f55e
Fixes #22882: Fix support for DISTINCT on nested GraphQL lists (#22892) 2026-08-10 09:52:01 -05:00
Jason Novinger f355a3de05 Fixes #22812: Address review — DB alias, batch size, MRO note
- batch_delete_jobs now writes through the same DB alias it reads from. In JobsMixin.delete
  the read queryset is bound to the instance's DB while Job.objects would use the router
  default; if those diverged on a multi-DB setup the deleted rows never left the read side
  and the batch loop never terminated.
- JobsMixin.delete and ScriptModule.delete honor a caller-supplied `using`, matching
  DeleteMixin.delete, instead of always recomputing it.
- Raise JOB_DELETE_BATCH_SIZE from 100 to 1000 and correct its rationale. With only('pk')
  the per-batch payload is gone, so the size now bounds per-cycle work rather than memory;
  1000 matches EXPORT_CHUNK_SIZE and was the fastest of 100/1000/5000 when benchmarked
  against a 200k-job deletion.
- Document that JobsMixin must precede DeleteMixin in the MRO or the batching is bypassed,
  and scope the ScriptModule.delete comment so it doesn't imply the on-disk file removal is
  transactional.
- Add a module-path rollback test alongside the existing script-path one.
2026-08-10 09:39:43 -05:00
Martin Hauser 53efbe0a00
Fixes #22805: Prevent repeated execution of LDAP configuration (#22809) 2026-08-10 09:04:16 -05:00
Jeremy Stretch 4b5fc1a260
#18645: Pre-release QA (#22873) 2026-08-07 16:48:41 -07:00
bctiemann 0984be8c04
#20897: Pre-release QA (#22864) 2026-08-07 16:38:32 -07:00
Martin Hauser 4660fbb0ab fix(ui): Improve dark mode form control contrast
Fixes form check input border contrast in dark mode by using solid grey
instead of translucent border. Updates checked checkbox glyph color to
rich black for better visibility against teal primary background.

Fixes #22879
2026-08-07 15:21:29 -04:00
Sri Chandraja Reddy Allala f7768e95dd
Fixes #22694: Clear stale Rack assignment when changing a Device's Site (#22764)
Prevent out-of-order dynamic select responses from restoring options for an
earlier dependency state.

Track the latest load request, preserve valid selections across superseding
loads, and properly finalize stale requests and their loading state. Clear any
pending restored value when a request cannot be made or fails.
2026-08-07 13:40:57 +02:00
github-actions a6451297a2 Update source translation strings 2026-08-07 05:30:32 +00:00
bctiemann 60e0973363
Merge pull request #22871 from netbox-community/22441-cleanup
#22441: Pre-release QA
2026-08-06 19:47:19 -04:00
Martin Hauser d61528e464
Fixes #22821: Prevent Tenant Group deletion from creating duplicate ungrouped Tenant names or slugs (#22830) 2026-08-06 15:08:41 -05:00
Jeremy Stretch 80231a9706
Closes #22835: Improve performance when provisioning new custom fields (#22866) 2026-08-06 14:56:22 -05:00
Jeremy Stretch d924937ef1 Keep completed as a default column 2026-08-06 15:14:26 -04:00
Jeremy Stretch b1ee8297d2 Closes #22877: Improve caching logic when retrieving custom fields via get_for_model() 2026-08-06 13:28:18 -04:00
Jeremy Stretch aed86db7e9 Revert implementation of elapsed_time for running jobs 2026-08-06 13:16:16 -04:00
github-actions e160359e6e Update source translation strings 2026-08-06 05:57:19 +00:00
Jeremy Stretch feaa8698a0 Move the negative-duration clamp out of humanize_duration()
humanize_duration() is a general-purpose helper, newly exposed as a template
filter, so clamping negatives inside it made every present and future caller
suppress the exact symptom of clock skew. It now renders a negative duration
with a leading minus sign, which also fixes the nonsensical output the divmod
decomposition previously produced for one (e.g. "-1d 23h 59m 55s").

The floor moves to Job.elapsed_time, which is the value NetBox displays and
covers the list, the detail panel, the script result view and runscript in one
place. The stored execution_time is untouched, so the API and exports still
surface the anomaly.

Also renames the sub-second branch's variable, which held a value in seconds
rather than milliseconds.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-05 19:38:15 -04:00
Jeremy Stretch 7f91228fbf Document that execution time sorts and filters differently
The jobs list sorts by the displayed value, so a running job orders by how
long it has been going, while execution_time__gte/__lte match only the
recorded column — a long-running job can therefore top a descending sort yet
be excluded by a filter on the same attribute.

Keeping the filters on the stored column is deliberate: the filterset is
shared with the REST API, where matching against a live, clock-dependent
value would make results non-reproducible. Document the distinction, along
with the export's use of the recorded value, rather than reconciling them.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-05 19:38:03 -04:00
Jeremy Stretch 4d3871009c Retain Job.duration as a deprecated property
Job.duration has been public since 3.4 and is reachable from user-authored
export templates as well as plugins, so removing it outright was a silent
breaking change. Restore the original implementation verbatim — including the
fallback to `created` when a job never started, and the preformatted string —
so existing templates keep working, and warn on access. Planned for removal
in v5.0, matching the rack legacy fields.

Note that elapsed_time deliberately does not reproduce the `created`
fallback: measuring from creation conflates queue wait time with execution
time, which is what the new field is meant to record.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-05 19:37:50 -04:00
Jeremy Stretch c9185e1eb7 Revert the DurationColumn extension and export execution_time verbatim
JobTable defines both render_execution_time() and value_execution_time(), so
django-tables2 never invoked DurationColumn for that column and the new
timedelta branch was unreachable and untested. Restore the column to its
minutes-only form and use a plain Column, which is what the table was
effectively getting anyway.

The export path also passed through the render path's clamping, so an
anomalous negative execution_time was normalized to zero in the one output
intended for analysis, and a running job's provisional elapsed time was
indistinguishable from a completed job's final value. Export the recorded
value verbatim and leave the still-running distinction to the UI.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-05 17:10:51 -04:00
Jeremy Stretch 26b5eb8a83 Label the job detail panel attribute "Execution Time"
Renaming the attribute to elapsed_time changed its auto-derived label to
"Elapsed time", disagreeing with the list column, the filter form, the API
field and the model docs. The derived label is also built at runtime before
being passed to gettext, so it would never have been extracted into the
message catalog. An explicit label addresses both.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-05 17:10:38 -04:00
Jeremy Stretch f427e61063 Fix elapsed_time_expression() for jobs completed without an execution time
The expression coalesced to Now() - started with no regard for whether the
job had finished, so a row with both started and completed set but a null
execution_time resolved to an ever-growing interval, while the elapsed_time
property returned None for the same row. Sorting the jobs table descending
by execution time therefore ranked those rows above every real value.

Gate the live branch on completed__isnull=True so the expression agrees with
the property.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-05 17:10:26 -04:00
Jeremy Stretch 5346dab1c3 Move the execution_time backfill into its own non-atomic migration
Batching the backfill bounded statement size but not lock duration: sharing
a transaction with the AddField meant the ACCESS EXCLUSIVE lock from ALTER
TABLE was held for the whole run, which is exactly the case the batching was
meant to help. 0025 goes back to adding the column only, and the backfill
moves to 0026 with atomic = False so the lock is released first.

The backfill now also skips rows which already have a value, making it
idempotent and letting an interrupted run simply be resumed. As a separate
migration it additionally reaches installations which had already applied
0025, rather than silently leaving their historical jobs unpopulated.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-05 17:10:13 -04:00
Jeremy Stretch bab3ccd216 Keep the job completion filters alongside the other scheduling fields
started__* and completed__* are two halves of the same time range, so
splitting them across the Scheduling and Execution field sets made a run
window awkward to filter. Execution now holds only execution_time, and the
grouping matches JobSchedulingPanel on the detail view.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-05 17:09:59 -04:00
Jeremy Stretch d642a43121
#22486: Pre-release QA (#22862)
Normalize RQ timeout values before validating global and per-webhook
timeouts, including duration strings and RQ's default and unlimited values.

Improve timeout logging and visibility in the UI and documentation, raise
the default webhook timeout to 60 seconds, and add coverage for the new
validation and filtering behavior.
2026-08-05 22:54:08 +02:00
Jeremy Stretch a633e80804 Revert OrderingFilter 2026-08-05 16:16:01 -04:00
bctiemann 1f5a30dcd2
Merge pull request #22859 from netbox-community/22825-circuit-term-fielddoesnotexist
Fixes #22825: Handle CircuitTermination origins in cable path tracing
2026-08-05 16:10:54 -04:00
Jeremy Stretch 17b2017e6b Drop DurationAttr 2026-08-05 15:58:13 -04:00
Jeremy Stretch 9a888a62fd Additional review feedback 2026-08-05 15:46:37 -04:00
Jeremy Stretch 93bf49b1ec Show job elapsed time 2026-08-05 15:46:18 -04:00
Jeremy Stretch bff5ee605a Ensure correct ordering by elapsed time 2026-08-05 15:43:00 -04:00
Jeremy Stretch 0088ebae8c Introduce custom OrderingFilter to control NULLs & include tiebreaker 2026-08-05 15:41:33 -04:00
Jeremy Stretch d873876fed Batch migration updates 2026-08-05 15:37:07 -04:00
Jason Novinger 6bd50ef07d Fixes #22812: Note ConfirmCollector is intentionally Job-specific 2026-08-05 14:27:22 -05:00
Jason Novinger 7d46c995f7 Fixes #22812: Defer large Job payload fields during batched deletion
The batched job delete can't fast-delete (a global pre_delete receiver forces
per-instance signals), so each batch still instantiates its Job rows. Load only the PK
via only('pk') so those instances don't pull the large data/log_entries payloads,
cutting the resident set per batch. Also drop a dead `no-toggle` CSS class from the
delete-confirmation template (it is defined nowhere and, under Tabler, has no effect)
and use JobStatusChoices.STATUS_COMPLETED in the tests instead of a string literal.
2026-08-05 14:04:19 -05:00
Jason Novinger be69c55a99 Fixes #22812: Don't show a spurious "0 jobs" row for jobless objects
Django's Collector calls into the jobs GenericRelation branch unconditionally, so
ConfirmCollector recorded a zero count for objects with no jobs. _get_dependent_objects
then added a CountOnly(0), and the delete-confirmation page rendered "The following
objects will be deleted as a result of this action." plus a "0 jobs" row for every
jobless JobsMixin object. Only record a count when there are actually jobs.
2026-08-05 13:59:02 -05:00
Jeremy Stretch cd7fdf2267 Display the duration for running scripts 2026-08-05 14:57:14 -04:00
Jeremy Stretch 736fd38e08 Clarify model documentation 2026-08-05 14:56:56 -04:00
Jason Novinger f2923f4ce4 Fixes #22812: Batch child-script job deletion when deleting a ScriptModule
Deleting a Script via the UI is only possible by deleting its parent ScriptModule
(no Script delete view exists). That cascades to the child Script rows, and the
collector materialized every one of those Scripts' jobs — the memory blowup, which
scales with jobs-per-script. JobsMixin.delete() only batched the deleted object's own
jobs, and a ScriptModule has none; the jobs live on its child Scripts.

Extract the chunked job-deletion loop from JobsMixin.delete() into a shared
batch_delete_jobs() helper, and add a ScriptModule.delete() override that batch-deletes
its child Scripts' jobs (in a single queryset keyed on the script PKs, no per-script
loop) before delegating to the cascade. This bounds peak memory to one batch regardless
of how many jobs the module's scripts hold.
2026-08-05 13:56:01 -05:00
Jeremy Stretch 011eb6da14 Improve table rendering 2026-08-05 14:55:18 -04:00