Commit Graph

15502 Commits

Author SHA1 Message Date
Jeremy Stretch e50683fee9 Merge main into feature 2026-07-21 09:09:58 -04:00
Martin Hauser cfbbceea4d
Closes #15289: Allow moving Modules between Bays and Devices (#22704)
Fixes #15289
2026-07-20 14:21:07 -05:00
Jeremy Stretch 036456dc54 Revert "Merge pull request #22013 from netbox-community/21988-authorization-bypass-in-nested-object-resolution-via"
This reverts commit b3489cd529, reversing
changes made to 41f792c53b.
2026-07-16 10:15:51 -04:00
bctiemann 6068f41787
Merge pull request #22646 from netbox-community/20054-bulk-error-correlation
Closes #20054: Return per-object error details for failed bulk operations
2026-07-14 22:13:14 -04:00
bctiemann 63984e693c
Update netbox/netbox/api/viewsets/mixins.py
Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com>
2026-07-14 22:13:05 -04:00
bctiemann 3df0bc8e62
Update netbox/netbox/api/viewsets/mixins.py
Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com>
2026-07-14 22:12:28 -04:00
Brian Tiemann b61c232305 Return errors-only response for bulk operations, drop error_count
Rename the 'results' key to 'errors' and omit successful objects from
the bulk create/update/destroy error response, applied consistently
across all three mixins. len(errors) replaces the separate error_count
bookkeeping. Also change the ProtectedError/RestrictedError entry's
'detail' key to '__all__' to match the field-based error format used
by creates and updates, and correct a comment that implied bulk delete
enforces a permission boundary the single-object delete endpoint
doesn't actually have.

Addresses review feedback from @jeremystretch.
2026-07-14 14:19:08 -04:00
bctiemann d13c98b9ea
Closes #19731: Add ModuleBayType to restrict which module types can be installed into a module bay (#22648)
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Closes #19731
2026-07-14 11:44:49 -05:00
bctiemann d88b6a65dd
Closes #18159: Expose snapshots to Event Rule condition evaluation (#22637)
Expose an event's prechange and postchange snapshots to event rule
condition evaluation, making snapshots.prechange.<attr> and
snapshots.postchange.<attr> available through the existing dot-path
syntax.

Add changed and unchanged snapshot operators for comparing an attribute
across the two snapshots without requiring a condition value. These
operators support rules such as firing only when a field transitions to a
specific state.

Make condition values optional only for snapshot operators by introducing
a missing-value sentinel, while preserving value requirements for all
other operators. Reject invalid combinations such as using changed or
unchanged with an explicit value or with an attr starting with snapshots.

Fail closed when condition paths traverse invalid snapshot structures,
including raw scalar snapshot values such as status strings, by treating
unresolvable snapshot-operator paths as missing and converting invalid
direct paths to InvalidCondition.

Document the new snapshot path syntax, changed and unchanged operators,
create/delete snapshot behavior, and the serialization differences
between snapshot data and REST API data. Add regression and integration
tests covering validation, transition behavior, null snapshot edge cases,
direct snapshot paths, and event rule evaluation.
2026-07-11 18:32:22 +02:00
Martin Hauser 8e525c89fb
feat(dcim): Support multiple Terminations per side in Cable bulk import (#22641)
Enable comma-separated Device, Power Panel, and Termination name lists
in Cable CSV/JSON/YAML imports. Each side accepts either one parent for
all terminations or one parent per name, preserving submission order for
connector assignment.

Add validation for duplicate terminations, empty names, parent count
mismatches, and MultipleObjectsReturned cases. Change side_a/b_device
and side_a/b_power_panel fields from CSVModelChoiceField to
CSVModelMultipleChoiceField with updated help text.

Fixes #18645
2026-07-10 10:27:31 -07:00
Brian Tiemann 48e08779d1 Drop explicit status key from bulk operation results
Success is now inferred from the absence of an errors key, matching
Jeremy's suggestion. Error entries carry only {id/index, errors};
successful entries carry only {id/index}. Update all tests accordingly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-09 15:24:09 -04:00
Brian Tiemann 3c77972f59 Address review feedback on bulk operation mixins
- Move single-object create back inside transaction.atomic() (comment 1)
- Replace repeated result-list iterations with local error_count counters
  in create(), perform_bulk_update(), and perform_bulk_destroy() (comments 3, 4, 6)
- Rewrite perform_bulk_update() from two-pass (validate-all, save-all) to
  sequential per-object validate+save, matching SequentialBulkCreatesMixin;
  subsequent validators now see DB state from prior saves so cross-object
  uniqueness conflicts are caught at validation time (comment 5)
- Update bulk_update() and bulk_destroy() callers to unpack new return tuples
  and use the counters directly

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-09 15:08:00 -04:00
bctiemann 517804758f
Merge pull request #22634 from netbox-community/22205-eol
#22205 - Add EOL to DeviceType, ModuleType
2026-07-09 14:50:14 -04:00
Brian Tiemann d1310ed580 Address PR #22646 review findings from automated reviewer
- Security: remove object names/PKs from ProtectedError detail; report count only
  to avoid exposing objects the caller may lack permission to view
- i18n: wrap new error detail strings with _().format() to match codebase convention
- Redundancy: remove superfluous `results and` guard in bulk_destroy (any() on an
  empty list already returns False)
- Comment: explain that SequentialBulkCreatesMixin continues provisionally creating
  after a failure so cross-object validators see a realistic state

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-08 18:42:05 -04:00
Brian Tiemann 94197efcfb Improve test_bulk_create_objects_validation_error with mixed ok/error case
Use a valid first item (create_data[0]) alongside an invalid second item ({})
so the test exercises both the 'ok' result shape and the atomic rollback of an
item that would otherwise have been persisted.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-08 18:11:34 -04:00
Brian Tiemann d8506f178e Address PR review feedback for #20054 bulk error correlation
- Use pre-captured `pk` consistently in perform_bulk_destroy error path
- Add comment clarifying the `if results:` sentinel in bulk_update
- Add per-field atomicity assertion to test_bulk_update_objects_validation_error
- Use ID-keyed dict instead of positional index in test_bulk_delete_objects_protected

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-08 18:04:44 -04:00
Brian Tiemann 3d8f8289d9 Closes #20054: Return per-object error details for failed bulk operations
Bulk update (PATCH), sequential bulk create (POST), and bulk delete (DELETE) on
list endpoints now collect per-object errors instead of aborting on the first
failure. When any objects fail, the entire operation is rolled back atomically
and a 400/409 response is returned with a structured payload:

  {
    "detail": "1 of 3 objects failed validation.",
    "results": [
      {"id": 1, "status": "ok"},
      {"id": 2, "status": "error", "errors": {"name": ["..."]}},
      {"id": 3, "status": "ok"}
    ]
  }

For bulk creates via SequentialBulkCreatesMixin the correlator is "index"
(zero-based position in the request list) since no IDs exist yet. For bulk
delete the status code remains 409 and the correlator is "id".

Successful operations are unchanged (200/201/204).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-08 17:10:25 -04:00
Arthur Hanson c3bc1fb04a
#22231 - Add nulls-first parameter for custom field ordering (#22476) 2026-07-08 11:45:53 -07:00
Arthur f9b5df87c5 fix 2026-07-08 10:45:34 -07:00
bctiemann 800db5727f
Closes #18821: Simplify setting/updating primary MAC through interface model (#22520) 2026-07-08 09:31:16 -07:00
Arthur Hanson 2f604551c1
Closes #22571: Migrate from django-pglocks to django-pgware (#22635) 2026-07-08 10:19:05 -05:00
Arthur 6fece9cfc2 fix 2026-07-07 16:42:39 -07:00
bctiemann b620be0f46
Merge pull request #22631 from netbox-community/22615-webhooks-drop-request_id-username
Closes #22615: Remove legacy request_id and username parameters from webhook context
2026-07-07 15:45:49 -04:00
Arthur 3f077df77f #22205 - Add EOL to DeviceType, ModuleType 2026-07-07 10:26:38 -07:00
Jeremy Stretch 58e8068958
#21355: Refactor trigger migrations (#22608) 2026-07-07 09:04:45 -07: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 9ed112b89d #21326: Fix tests for updated VC search behavior 2026-06-30 12:40:54 -04: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 1a12f687ee fix(extras): Conditionally render saved filter dropdown
Only display the saved filter dropdown in table controls when a filter
form is present and includes a filter_id field. This prevents rendering
an empty or non-functional dropdown when saved filters are unavailable.
2026-06-30 11:21:19 -04:00
Martin Hauser 8c898e7713 fix(navigation): Normalize default menu button color
Render navigation menu buttons with the secondary ghost style when their
color is unset or set to the default choice.

This fixes plugin menu buttons, which default to "default" rather than
None, while preserving explicitly configured button colors.
2026-06-30 11:21:19 -04:00
Martin Hauser f027b0b206 feat(navigation): Improve sidebar action button styling
Replace the grouped button wrapper with a semantic
`dropdown-item-buttons` container and render sidebar action buttons with
the `btn-ghost` style while preserving existing color support.

Scope dropdown item link styles to direct child anchors so nested action
buttons keep their intended styling, and reveal the buttons on hover,
active, and focus-within states.
2026-06-30 08:24:30 -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
Jason Novinger b86145fe54
Closes #22561: Fix AttributeError when importing IPs with is_primary/is_oob set but no device (#22564)
Move the device/VM lookup ahead of is_primary/is_oob handling and only
process those flags when a parent device or VM exists.

This avoids dereferencing None for explicit falsy CSV values such as
"false", which are not covered by the column-absent checks in
clean_is_primary() and clean_is_oob(). This also keeps the behavior
aligned with MACAddressImportForm.
2026-06-29 17:40:43 +02:00
Arthur Hanson e1f0c18c74
Closes #20897: Expose selection custom field labels in the REST API (#22475) 2026-06-29 04:54:08 -05:00
Martin Hauser 0e5cbed3f6
Fixes #22501: Fix GraphQL API exceptions falling back to HTML error responses (#22552) 2026-06-29 03:45:30 -05:00
github-actions 34c3c81c61 Update source translation strings 2026-06-27 06:10:30 +00:00
Jeremy Stretch 4f4e97f1a6
Fixes #22530: Remove hidden select inputs from the accessibility tree (#22541) 2026-06-26 10:26:42 -07:00
Martin Hauser 9f140e6442
fix(extras): Prevent Script uploads from overwriting files (#22554)
Reject duplicate ScriptModule uploads before writing to storage to
prevent failed uploads from corrupting existing files. Add existence
check in cleanup path to avoid deleting files referenced by concurrent
uploads that won the race.

Fixes #22543
2026-06-26 10:19:12 -07:00
Jeremy Stretch 80a243045e
Fixes #22529: Ensure navigation menu is navigable via keyboard (#22540) 2026-06-26 10:14:06 -07:00
Jeremy Stretch 18fc16df8e
Closes #20547: Consolidate unique constraints comprising nullable fields (#22549) 2026-06-26 18:51:09 +02:00
Martin Hauser 021b7c5f5b
Closes #22174: Include DNS names for primary/OOB IPs and NAT data for VDCs (#22553) 2026-06-26 11:34:30 -05:00
Jeremy Stretch 68c1153325
Closes #22526: Avoid query timeouts when updating custom fields on a large number of objects (#22556) 2026-06-26 11:22:15 -05:00
Jamie (Bear) Murphy 2f87dab011
Closes #21710: Support multi-select fields for module type profile array enums (#22495) 2026-06-26 12:19:18 -04:00
Martin Hauser 4da65854e1 feat(dcim): Add 1C8P:8C1P breakout cable profile
Introduce Breakout1C8Px8C1PCableProfile to map a single 8-position
connector to eight single-position connectors. Add profile choice,
registration, and bidirectional link peer tests for the new breakout.

Fixes #22279
2026-06-26 12:08:22 -04:00