Commit Graph

4147 Commits

Author SHA1 Message Date
Jeremy Stretch 891e40ffb4 Closes #20285: Support for multi-protocol application services 2026-07-08 10:43:27 -04:00
Jeremy Stretch 80c81230a4 Closes #22615: Remove legacy request_id and username parameters from webhook context 2026-07-07 11:13:09 -04:00
Jeremy Stretch df83277156
Closes #22607: Sanitize HTTP requests passed to template contexts for custom links (#22616) 2026-07-07 08:59:24 -05:00
bctiemann a6da836df8
Merge pull request #22580 from netbox-community/21712-static-select-descriptions
Closes #21712: Support description annotations for static choice form fields
2026-07-06 14:47:18 -04:00
Jeremy Stretch a907ba2062
#21992: Additional cleanup (#22594) 2026-07-06 09:45:45 -05:00
Jeremy Stretch a7be755e01 Closes #21712: Support description annotations for static choice form fields 2026-07-02 13:46:43 -04:00
Jeremy Stretch 48ce5e7e2c
Closes #22446: Add breadcrumbs support for Layouts (#22546) 2026-07-02 10:46:01 -05:00
Jeremy Stretch d28f0a2114 Merge branch 'main' into feature
Resolved conflicts:
- Dropped 4.7 deprecation shims (FutureWarning getattr/methods) re-introduced
  by main, which feature has already removed: pagination, constants, registry,
  forms utils/expandable, settings (Sentry), generic view mixins.
- dcim/signals.py: kept main's search-cache-on-VC-rename handler; dropped
  Prefix/Cluster/WirelessLAN imports for the scope-sync handler feature replaced
  with PostgreSQL triggers.
- extras test_management_commands.py: unioned ConfigContext + ImageAttachment
  imports.
- Rebuilt project-static dist bundles (netbox.js/.map/.css) from merged source.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-30 11:32:37 -04:00
Jeremy Stretch 3d73b2a166 Release NetBox v4.6.4 2026-06-30 11:23:11 -04:00
Martin Hauser b6bdfbd2a5
Closes #19821: Consolidate GFK form handling with GenericObjectChoiceField (#22537)
* refactor(forms): Add GenericObjectChoiceField

Replace separate scope_type/scope and parent_object_type/parent field
pairs with unified GenericObjectChoiceField. Introduce
GenericObjectFormMixin to handle GFK descriptor initialization and
assignment.

This removes redundant HTMX/queryset setup logic from ScopedForm,
VLANGroupForm, and ServiceForm by delegating GFK presentation to a
single reusable field and mixin pair. Field query param references now
use `$scope_object_id` instead of `$scope` to match the subwidget name.

Fixes #19821

* fix(forms): Skip validation on HTMX bulk-edit dependent field refresh

Render bulk-edit form unbound when an HTMX request changes a dependent
field (e.g. content type) without clicking Apply. This prevents
validation errors from surfacing before the user submits.

Cache ContentType lookups in GenericObjectChoiceField and sync widget
references before setting queryset to ensure choices land on the
rendered subwidget.

* fix(ipam): Update scope query params for GenericObjectChoiceField

Change available-prefix Add links to use `scope_content_type` and
`scope_object_id` query parameters instead of `scope_type` and `scope`.
This aligns with the GenericObjectChoiceField subwidget naming
introduced in the earlier refactor.

* refactor(models): Simplify GFK handling in clone_fields

Replace `scope_type`/`scope_id` pairs with bare `scope` GFK names in
clone_fields across models. Update CloningMixin to emit GFK subwidget
parameters (`scope_content_type`, `scope_object_id`) directly when a
GenericForeignKey appears in clone_fields.

* Update pre-populated links

---------

Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com>
2026-06-29 16:44:33 -04:00
Arthur Hanson e1f0c18c74
Closes #20897: Expose selection custom field labels in the REST API (#22475) 2026-06-29 04:54:08 -05:00
bctiemann 4daa1a0165
Merge pull request #22524 from netbox-community/22441-exec-time-jobs-table
Closes #22441: Add execution_time to background jobs
2026-06-24 18:54:33 -04:00
Jason Novinger 2dcc98b41e
Closes #21326: Defer global search cache updates to a background job (#22481)
Defer CachedValue updates from post_save/post_delete signal handlers to a
SearchCacheJob that runs after the surrounding transaction commits. Coalesce
pending updates per database alias and savepoint scope, preserving rollback
semantics while reducing synchronous write latency.

When no worker is available, or Redis cannot be reached during dispatch, apply
the update inline so existing single-process installs continue to behave
correctly. Replay the originating database alias during deferred reads and
writes so cache updates remain routed to the schema that emitted the signal.

Keep deferral private to CachedValueSearchBackend so custom SEARCH_BACKEND
implementations continue to use the existing synchronous cache/remove contract.
Move the job runner to search/jobs.py and keep the CachedValue-specific update
logic on the backend.

Document the eventual consistency of global search results and add coverage for
coalescing, rollback/savepoint behavior, worker dispatch, inline fallback,
deleted objects, and the custom backend contract.
2026-06-24 17:48:55 +02:00
Jason Novinger e7e1362c35 Closes #22441: Add execution_time field to background jobs
Adds a nullable DurationField computed as completed - started, set in
Job.terminate(). Exposes it as an orderable table column, detail-panel
attr, REST API field, and UI/API range filters (execution_time__gte /
execution_time__lte).

A plain stored field (not a GeneratedField) keeps the migration
metadata-only, avoiding a full table rewrite on core_job.
2026-06-24 16:39:59 +02:00
Jason Novinger d7c566aee6
Closes #22169: Cache image file size on ImageAttachment (#22465) 2026-06-23 08:40:19 -07:00
Jeremy Stretch 482537c72f
Closes #22393: Drop support for Redis 5.x (#22471) 2026-06-22 02:49:34 -05:00
mburggraf d217acdc85
Closes #22487: Remove release notes for NetBox v2.x (#22490) 2026-06-18 14:55:59 -04:00
mburggraf f9ce0a6741
Closes #22464: Update Documentation to use v2 Tokens in examples (#22477) 2026-06-17 13:44:29 -07:00
Jeremy Stretch bf954f08d6 Merge branch 'main' into feature 2026-06-16 14:55:03 -04:00
Jeremy Stretch 0c26f973ff Release v4.6.3 2026-06-16 11:59:12 -04:00
Jeremy Stretch 288c47d445
#21025: Optimize rendering of config context data (#22294)
* #21025: WIP

* Fixes #22357: Remove unused `local_context_data` field from dcim.Module (#22364)

* Add partial index for checking null CC data

* Ensure the data returned by get_config_context() is safe for mutation

* Implement selective backup queryset annotation to avoid n+1 overhead on cold cache

* Fix migration conflict

* Replace MPTT with Ltree per #21418
2026-06-16 08:41:11 -07:00
Jason Novinger 89504b2502
Closes #21992: Enable background job support for REST API bulk requests (#22452)
Bulk write operations (create/update/delete a JSON list at a model's list
endpoint) can opt into background processing with the ?background=true query
parameter. The request is validated synchronously and, if accepted, an
AsyncAPIJob is enqueued and a 202 Accepted is returned with the job id and
poll URL; the write is performed later by a worker that re-invokes the same
viewset action, so behavior matches the synchronous path (including
all-or-nothing transaction semantics).

- AsyncAPIJob reconstructs the request in the worker, re-applies object
  permissions, runs within the request processors (change logging/events),
  and captures the action's response into job.data as {status_code, data}.
- Handled rejections are translated to match the synchronous API: APIException
  via handle_exception(), and AbortRequest/ProtectedError/RestrictedError via a
  new NetBoxModelViewSet.exception_to_response() helper. These terminate the
  job as "failed" (reserving "errored" for unexpected crashes).
- Background processing is refused with 503 when no worker is servicing the
  queue, and rejected with 400 when combined with an If-Match precondition
  (which cannot be honored once execution is deferred).
- Single-object writes, GET requests, and non-list payloads ignore the
  parameter and run synchronously.

exception_to_response() intentionally duplicates the translation logic in
dispatch() rather than dispatch() being refactored to call it; consolidating
the two is left as a follow-up to keep this change off the synchronous hot path.

* Address code review feedback (#21992)

- Carry the request's scheme and host into the background worker so absolute
  URLs in the captured job result point at the real server instead of a
  hardcoded http://localhost/.
- Emit the same protected-delete warning log in exception_to_response() that
  dispatch() produces, restoring application-log parity for background failures.
- Drop the inert `_authenticator = None` assignment: setting request.user
  already prevents lazy re-authentication via the public API, and nothing on
  the worker's action path reads the authenticator.
- Remove the redundant success-path job.save() (JobRunner.handle() ->
  terminate() persists job.data) and hoist the AsyncAPIJob import in mixins.py
  to module level (no real import cycle through it).
- Add a test asserting result URLs reflect the request host.

* Fix IPv6 host parsing in background API request reconstruction

Parse the carried host with urlsplit (and pass it verbatim as HTTP_HOST)
instead of host.partition(':'), which split bracketed IPv6 hosts like
[::1]:8443 on their inner colons. Extract request construction into
AsyncAPIJob._build_request and add a test asserting the IPv6 host round-trips.

* Address review feedback (#21992)

- Make the bulk mixins safe to use without BackgroundOperationMixin: guard the
  _background_requested / _maybe_background_bulk_create calls with a getattr
  fallback so BulkUpdateModelMixin/BulkDestroyModelMixin/SequentialBulkCreatesMixin
  retain their standalone behavior in custom viewset composition.
- Add a test covering the background ProtectedError/RestrictedError path: a bulk
  delete of a protected object records the same 409 the synchronous API returns
  (job failed, status_code 409, object preserved), via exception_to_response().
2026-06-16 12:48:17 +02:00
Arthur 57094ffdfd #21355 - Handle updates to denormalized data via PostgreSQL triggers 2026-06-15 09:18:17 -07:00
Martin Hauser d7de863681
Closes #17598: Add bulk creation for VLANs (#22377) 2026-06-15 08:22:58 -05:00
Brian Tiemann ac513345b5 Closes #22436: Rename jinja2_filters/get_jinja2_context/register_jinja2_filters to drop the '2' suffix
Follow-up to #22363: align the plugin hook names with the already-renamed
JINJA_FILTERS setting (#22288) and with the rest of the codebase's 'Jinja'
spelling convention.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-12 09:20:42 -04:00
Jeremy Stretch 9f905cf842 Closes #22288: Rename JINJA2_FILTERS to JINJA_FILTERS 2026-06-09 14:49:31 -04:00
Jeremy Stretch 814050a3c9 Closes #22409: Disallow chosen-plaintext API tokens 2026-06-08 14:14:30 -04:00
Jeremy Stretch 70391e5a0b
Closes #22392: Deprecate support for Redis 5.x (#22405) 2026-06-08 09:28:31 -07:00
bctiemann 5b6d7887f2
Closes #22351: Add jinja2_filters plugin hook and get_jinja2_context() for config template extensibility (#22363) 2026-06-05 13:29:32 -07:00
Jeremy Stretch d592afe56c Closes #22349: Correct documentation to reflect minimum Redis version of 5.0 2026-06-04 14:57:03 -04:00
Jeremy Stretch 839259ccec
Closes #22361: Introduce ArrayAttr UI panel attribute (#22362) 2026-06-02 18:17:02 +02:00
Jeremy Stretch 0b002c1b6e Merge branch 'main' into feature 2026-06-02 10:25:04 -04:00
Jeremy Stretch 742f4b4330 Release v4.6.2 2026-06-02 10:11:34 -04:00
Jeremy Stretch 7022bb7eac
Closes #22109: Add template object counts to ModuleType representation in REST & GraphQL APIs (#22302) 2026-05-27 09:38:47 -07:00
Jeremy Stretch 4d8dbc6ffe
Closes #22212: Support for exposing environment parameters in Jinja template context (#22289) 2026-05-26 13:47:04 -05:00
Jeremy Stretch a89feaf856 Closes #22090: Extend test cases to analyze the number of SQL queries executed 2026-05-26 09:10:03 -04:00
mburggraf 57e7884d83
Closes #21261: add quick_add parameter to ObjectVar (#22271) 2026-05-22 13:38:58 -05:00
Arthur ff26cbd521 cleanup 2026-05-22 14:12:17 -04:00
Arthur b09e8a1808 cleanup 2026-05-22 14:12:17 -04:00
bctiemann 2580b321a3
Closes #19460: Support {lat}/{lon} placeholders in MAPS_URL (#22243)
Add support for literal `{lat}` and `{lon}` placeholders in `MAPS_URL`
when rendering GPS coordinate links. Existing configurations continue to
work by falling back to appending `lat,lon` when no coordinate placeholders
are present.

Move map URL handling into shared UI helpers so `GPSCoordinatesAttr` and
`AddressAttr` use consistent placeholder detection. When `MAPS_URL` contains
coordinate placeholders, suppress address-based map links to avoid rendering
invalid URLs.

Add tests for placeholder replacement, decimal coordinate values, fallback
behavior, and address link suppression. Also document the address link behavior
in the `MAPS_URL` configuration description.
2026-05-22 12:35:14 +02:00
bctiemann e15b7bd8ac
Merge pull request #22244 from netbox-community/22228-vlangroupsave-doesnt-validate-vid_ranges-bounds-metadata
Fixes #22228: Correct VLAN Group total VLAN ID calculation for non-canonical VID ranges
2026-05-20 20:39:46 -04:00
Martin Hauser 62b3d8f615 docs(customization): Add model validation guidance for Custom Scripts
Adds warning and examples for validating NetBox objects before saving
in Custom Scripts. Direct ORM writes bypass UI/API validation and can
introduce invalid data. Recommends calling `full_clean()` explicitly.

Fixes #22249
2026-05-20 12:52:36 -04:00
Martin Hauser 573b1b0634
fix(ipam): Correct VLAN ID range bound handling in VLANGroup
Fix miscounting of total_vlan_ids when VLANGroup vid_ranges use
non-canonical bounds (e.g. '[]'). Normalize ranges to '[)' on save and
add migration to recompute existing totals. Prevent division-by-zero in
utilization queries for legacy rows with miscounted totals.

Fixes #22228
2026-05-20 14:45:01 +02:00
Jeremy Stretch 64d3b114bc Release v4.6.1 2026-05-19 11:16:49 -04:00
Jeremy Stretch 7e44f88d11
Replace legacy installation graphics with mermaid.js diagrams (#22229) 2026-05-19 11:35:49 +02:00
Martin Hauser d2545c4bda
docs(plugin): Update plugin installation examples (#22185) 2026-05-14 13:36:00 -07:00
Jeremy Stretch 329c041224
Closes #22192: Introduce HTTP_CLIENT_IP_HEADERS configuration parameter (#22197) 2026-05-14 17:04:30 +02:00
Martin Hauser f66e6f360a feat(ipam): Allow single-address IP Ranges
Allow IP ranges where start_address equals end_address to model
single-IP pools like DHCP or NAT reservations. Add validation tests,
filterset coverage, and display logic to render both endpoints.

Fixes #21993
2026-05-14 08:05:51 -04:00
Jeremy Stretch 2e9c3119ce
Closes #22060: Introduce a config parameter to enforce GraphQL maximum query depth (#22162) 2026-05-11 19:54:07 +02:00
Jeremy Stretch 2703ff98a3
Closes #22128: Deprecate v1 API tokens (#22143)
Display a warning in the UI whenever a user goes to provision a v1
token (both via the admin token form and the user profile token form).
Update documentation to note that v1 tokens are deprecated and will be
removed in NetBox v5.0.
2026-05-07 08:48:25 -07:00