Commit Graph

15872 Commits

Author SHA1 Message Date
Jason Novinger 97b717f552 Revert "Note the CI dulwich install in the Git backend test docstring"
This reverts commit 5959f915fa.

That commit existed only to touch a .py file so CI's path filter would run
the test suite against the dulwich install in the preceding commit. The
docstring change itself is not worth keeping.
2026-09-11 03:17:00 -05:00
Jason Novinger 5816e25b81 Populate bulk_update_invalid_data for the remaining API tests
Cover virtualization, tenancy, users, wireless and core so
test_bulk_update_objects_validation_error runs instead of skipping. Every
class in the suite that sets bulk_update_data now sets an invalid payload
alongside it.

Two cases needed care. DataSource's status is read-only on its serializer,
so a bogus status would have been ignored rather than rejected, and it
uses a nonexistent owner pk instead. OwnerGroup exposes only name,
description and a read-only member_count, so an over-length description is
the only value that can fail validation there. A comment records why.
2026-09-11 03:00:39 -05:00
Jason Novinger d23b8a2d07 Populate bulk_update_invalid_data for circuits API tests
Give each circuits test class an invalid payload so
test_bulk_update_objects_validation_error runs instead of skipping.

Four classes have neither a choice field nor a colour field on their
serializer and use a nonexistent FK pk instead. owner is absent from the
circuit termination, circuit group assignment and virtual circuit
termination serializers, so it was only used where it is actually present.

All 11 circuits API test classes now run the test.
2026-09-11 02:57:44 -05:00
Jason Novinger 1ec29cfc02 Populate bulk_update_invalid_data for vpn API tests
Give each vpn test class an invalid payload so
test_bulk_update_objects_validation_error runs instead of skipping.

Most vpn models carry several choice fields, so these mostly use one of
those. TunnelGroup has none and uses a nonexistent owner pk, matching the
organizational models in dcim, and L2VPNTermination uses a nonexistent
l2vpn pk because its other relations are read-only.

IPSecPolicy uses a non-numeric pfs_group value, since the Diffie-Hellman
group choices are integers.

All 10 vpn API test classes now run the test.
2026-09-11 02:56:55 -05:00
Jason Novinger de595f6a98 Populate bulk_update_invalid_data for extras API tests
Give each extras test class an invalid payload so
test_bulk_update_objects_validation_error runs instead of skipping.

extras serializers are more varied than dcim's, so fewer classes had a
plain choice field to work with: the config context and template classes
use a nonexistent data_source pk, and the saved filter, table config,
export template and subscription classes use an invalid content type.

Two fields were deliberately avoided. CustomField uses filter_logic rather
than type, because validate_type rejects any type change on an existing
instance and would fail for the wrong reason. EventRule uses action_type
rather than event_types, whose ArrayField choices do not map to a reliable
serializer error.

All 16 extras API test classes now run the test.
2026-09-11 02:54:42 -05:00
Jason Novinger 17ebddd0f2 Populate bulk_update_invalid_data for ipam API tests
Give each ipam test class an invalid payload so
test_bulk_update_objects_validation_error runs instead of skipping,
following the same preference order used for dcim.

Three classes needed something other than the obvious choice: Aggregate's
family is read-only on the serializer, and FHRPGroupAssignment and
VLANTranslationRule do not mix in OwnerMixin, so all three use a required
FK instead.

All 18 ipam API test classes now run the test.
2026-09-11 02:41:14 -05:00
Jason Novinger ad8730151f Populate bulk_update_invalid_data for dcim API tests
test_bulk_update_objects_validation_error skips unless a test class sets
bulk_update_invalid_data, and only SiteTestCase did, so the test has been
skipping for nearly every model since it was added.

Give each dcim test class an invalid payload, preferring a real choice field
where the model has one, then a validated ColorField, then a nonexistent FK
pk. Note that component template serializers have no owner field, so those
classes use an FK instead.

All 53 dcim API test classes now run the test.
2026-09-11 02:27:10 -05:00
Jason Novinger 5959f915fa Note the CI dulwich install in the Git backend test docstring
The docstring said these tests require dulwich without saying where that
comes from. Point at the CI install now that one exists.
2026-09-11 01:47:59 -05:00
Jason Novinger ad10aa3381 Fixes #23046: Install dulwich in CI so Git backend tests run
dulwich is the optional 'git' extra and is not in requirements.txt, so CI
never had it installed. The four GitBackendCredentialIntegrationTestCase
tests added in #21252 have therefore been skipped since they were written,
leaving the Git data source credential handling without CI coverage.

These tests mock dulwich.porcelain.clone, so they only need the module to be
importable. Installing it in the test environment does not change what a
NetBox deployment pulls in: dulwich stays optional at runtime, as decided in
#12906.
2026-09-11 01:45:19 -05:00
github-actions 6385c09837 Update source translation strings 2026-09-10 05:02:27 +00:00
bctiemann 5de246563b
Merge pull request #23144 from netbox-community/23096-partial-cable-length-saves-leave-the-normalized-length-out
Fixes #23096: Keep normalized cable length in sync during partial saves
2026-09-09 14:03:29 -04:00
github-actions d2191e0fb3 Update source translation strings 2026-09-09 05:02:18 +00:00
Martin Hauser dfb99e1f69
Fixes #23125: Add missing standard REST API fields for VLAN Translation Policies and Rules (#23127) 2026-09-08 13:40:29 -05:00
Martin Hauser 90675dbbab
fix(dcim): Persist normalized cable length on partial saves
Cable.save() recomputed _abs_length in memory but never added it to
update_fields, so a save naming length or length_unit left the stored
normalized value stale. Derive it from the values the row will hold
after the save and persist it alongside its source fields.

Fixes #23096
2026-09-08 18:53:51 +02:00
Martin Hauser 7b56158d47
Closes #23145: Prevent advisory lock cleanup races in Custom Field tests (#23146) 2026-09-08 11:43:20 -05:00
Martin Hauser 7ae8e4461f
fix(filters): Preserve contains lookup for negated multiselect filters (#23128)
Add FILTER_ARRAY_BASED_LOOKUP_MAP to maintain 'contains' lookup under
negation for MultiValueArrayFilter, preventing fallback to exact match.
Negation now correctly excludes objects whose array contains the value
rather than matching it exactly.

Fixes #23117
2026-09-08 08:43:08 -07:00
Martin Hauser 5685c5218e
Revert "Fixes #23097: Prevent duplicate Cable Paths when Cable Terminations …" (#23149)
This reverts commit 1745a7d9aa.
2026-09-08 17:25:35 +02:00
Martin Hauser 6895fb76c0
Fixes #23120: Fix REST API serialization and assignment of Data Source tags (#23126) 2026-09-08 09:44:47 -05:00
github-actions 46b6a17ae0 Update source translation strings 2026-09-08 05:02:43 +00:00
Arthur Hanson c9a62254d7
Fixes #22750: Validate Custom Script input and resolve object IDs in the REST API (#23119)
Validate REST script input before enqueueing jobs. Resolve ObjectVar
IDs to model instances and MultiObjectVar IDs to querysets, returning
HTTP 400 with errors nested under data when validation fails.

Share form preparation between the API and UI, including multi-value
defaults, while keeping validation out of the job runner to preserve
other execution paths. Exclude only known execution fields from script
data and prevent _notifications from leaking into CLI script input.

Document the REST compatibility changes, including required-field
validation and discarded undeclared keys. Add regression coverage for
object resolution, defaults, validation errors, and execution options.

Co-authored-by: Martin Burggraf <martin.burggraf@netclusive.com>
2026-09-07 13:11:14 +02:00
github-actions eaf30a6fb0 Update source translation strings 2026-09-05 05:02:38 +00:00
Martin Hauser 1745a7d9aa
Fixes #23097: Prevent duplicate Cable Paths when Cable Terminations are unchanged (#23100)
* fix(dcim): Prevent path rebuild when Cable Terminations unchanged

Compare Cable Terminations against stored values instead of the empty
cache when checking for modifications, so a freshly loaded Cable that is
resaved with the same terminations no longer rebuilds its paths. Raise
the flag whenever update_terminations() force-recreates an end, since
the edit form warms the cache that gated it and a profile change then
tore every path down without rebuilding it. Add regression tests for
both.

Fixes #23097

* fix(dcim): Preserve cable end order when terminations unchanged

Compare cable terminations against stored values instead of potentially
stale prefetched relations when checking for modifications. Skip setting
terminations in the form's clean() when a saved cable's members are
unchanged, preserving the connector order assigned by the profile.
2026-09-04 14:02:59 -04:00
Jason Novinger 2d519ece58 Fixes #22569: Ensures that Script Run OpenAPI operation is present
Does two things:
1. Adds a regression test to ensure that the `extras_scripts_run`
   operation is always present in contrib/openapi.json. This has
   regressed at least once since original implementation, so I wanted to
   make sure we catch it quickly in the future.
2. Overrides the Django `CACHES` setting for the OpenAPISchemaTestCase,
   which contains the new test, so that caching of the schema is
   disabled. This caused problems by masking whether or not the
   regression test (and other existing tests) were failing/succeeding in
   response to changes or not.
2026-09-03 08:55:12 -04:00
Jeremy Stretch 5f06007e4c Release v4.7.0 2026-09-02 14:40:04 -04:00
github-actions 8974a98317 Update source translation strings 2026-09-02 16:46:35 +00:00
Jeremy Stretch 8cc4548e1f
Merge pull request #23103 from netbox-community/feature
Merge `feature` into `main`
2026-09-02 12:31:21 -04:00
Martin Hauser 1afaf2de06 fix(templates): Update PostgreSQL version requirement to 15
Updates exception message to reflect PostgreSQL 15 as the minimum
supported version instead of version 14.
2026-09-02 12:15:02 -04:00
Jeremy Stretch a4ff5c7c28
Restore v4.6 migration ordering (#23107) 2026-09-02 17:31:25 +02:00
Jeremy Stretch dcd20089ba
Fix cross-worker cache contamination in parallel test runs (#23106)
RQQueueTestMixin cleared RQ queues with FLUSHALL, which empties every
database on the Redis server — including the caching database, whose
'config'/'config_version' keys are shared by all parallel test workers.
A flush landing mid-test forces an unrelated worker to re-read
core_configrevision, adding two queries to the affected request. Flush
only the queue's own database instead.

Also stop GraphQLDeferredColumnTestCase from comparing total query counts
between two requests, which is what surfaced the race as intermittent
"Query count grew from 7 to 9" failures in CI. Assert that the target
table is read exactly once per request instead, as #23034 did for the
equivalent custom fields test.
2026-09-02 15:47:34 +02:00
github-actions 1fae2d0111 Update source translation strings 2026-09-02 05:02:56 +00:00
Jeremy Stretch 56693d62ae Merge branch 'main' into feature
# Conflicts:
#	contrib/openapi.json
#	netbox/core/forms/filtersets.py
#	netbox/core/tests/test_openapi_schema.py
#	netbox/dcim/forms/mixins.py
#	netbox/extras/events.py
#	netbox/ipam/forms/bulk_edit.py
#	netbox/ipam/forms/model_forms.py
#	netbox/ipam/models/services.py
#	netbox/ipam/tests/test_forms.py
#	netbox/ipam/tests/test_models.py
#	netbox/ipam/tests/test_views.py
#	netbox/netbox/jobs.py
#	netbox/project-static/dist/netbox.js
#	netbox/project-static/dist/netbox.js.map
#	netbox/release.yaml
#	requirements.txt
2026-09-01 16:46:44 -04:00
Jeremy Stretch 560da79ea1 Release v4.6.10 2026-09-01 15:07:36 -04:00
Martin Hauser 9aa0c5c605
Fixes #23072: Rebuild cable paths when applying or changing a cable profile (#23091)
Set `_terminations_modified` flag when recreating terminations to ensure
paths are rebuilt even when endpoints remain unchanged.
Reset `_orig_status`, `_orig_profile`, and `_terminations_modified`
after saving a cable to prevent repeated saves from recreating
terminations and paths.
Add comprehensive test coverage for profile changes, trunk regrouping,
and mid-span cables.
2026-09-01 17:46:17 +02:00
Jeremy Stretch 6345ed1de2
Misc. cleanup ahead of the v4.7.0 release (#23084) 2026-09-01 08:32:44 -07:00
Jeremy Stretch 4d8c0bf80c
Fix omission of Service protocol field from the OpenAPI request schema (#23085) 2026-09-01 08:32:00 -07:00
Jason Novinger a39d5626fe
Closes #22872: Validate custom script Meta values before enqueueing (#23068)
Validate the effective timeout and notification settings at the
ScriptJob enqueue boundary so invalid script configuration is reported
consistently across all execution paths instead of raising an unhandled
exception.

Preserve the inherited positional enqueue contract and prevent tests
from interfering through shared RQ queue state during parallel runs.
2026-09-01 16:35:09 +02:00
Jeremy Stretch f535a47db2
Fixes #23090: Fix filtering of jobs by user in UI (#23092) 2026-09-01 15:41:21 +02:00
bctiemann f66ce9818a
Merge pull request #23071 from netbox-community/22989-nested-schema-components
Closes #22989: Reference brief components for nested SerializedPKRelatedField
2026-09-01 08:24:26 -04:00
github-actions cc112619ae Update source translation strings 2026-09-01 05:02:13 +00:00
Martin Hauser f64bf0b217 fix(models): Normalize update_fields to prevent iterable consumption
Introduces normalize_update_fields() utility to materialize one-shot
iterables like generators into frozensets, preventing bugs in save()
overrides that perform membership tests. Fixes channelization cascades,
module moves, and ltree parent tracking when using generator
expressions.

Fixes #23074
2026-08-31 13:50:59 -04:00
Martin Hauser 2b3b9e62e7
perf(api): Prefetch reverse many-to-many serializer fields (#23064)
Recognize Django's ManyToManyRel in get_prefetches_for_serializer().
Because it is a sibling of ManyToOneRel rather than a subclass, reverse
many-to-many accessors were omitted from the generated prefetch paths and
fetched once per serialized object.

Add regression coverage for both automatically generated fields and
SerializedPKRelatedField(many=True), and regenerate the affected ASN and
ObjectPermission API query-count baselines.

Fixes #23060
2026-08-31 10:15:21 -07:00
Martin Hauser 0f22d67617 fix(models): Normalize update_fields to prevent generator consumption
Introduce `normalize_update_fields()` utility to convert update_fields
to frozenset, preventing one-shot iterables from being consumed during
membership tests. Update Service, VLANGroup, and CircuitTermination
save methods to use normalized fields. Add comprehensive test coverage.

Fixes generator exhaustion when save() overrides check field membership
before persisting denormalized caches alongside their source fields.

Fixes #23078
2026-08-31 12:48:51 -04:00
Martin Hauser 60f80c8ad2 fix(forms): Assign scope before validation in ScopedForm mixin
Move scope assignment before validation to prevent stale scope values
on instances when validation fails. Refactor VLANGroupForm to inherit
from ScopedForm, removing duplicate scope handling code. Add test
coverage for scope type changes and validation errors.

Fixes #23040
2026-08-31 12:36:11 -04:00
github-actions dcc6afcf30 Update source translation strings 2026-08-29 05:02:16 +00:00
Peter Eckel 15565a1709 Add the Redis username to the Django default cache settings 2026-08-28 16:18:09 -04:00
Jeremy Stretch 443a22706f Avoid renaming existing schema components
Serializers used only in a nested context have no complete form in the schema, so
prefixing them with "Brief" renamed an existing component to no purpose and dropped
the old name entirely. Exempt serializers declaring an explicit Meta.ref_name from
the prefix, and pin the three affected names.

This narrows the schema diff to the fields the bug actually affected: no components
are removed, and the nine which are added are purely additive.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-28 15:55:51 -04:00
Jeremy Stretch 9a37694d22 Address review feedback on #22989
* Drop the non-BaseModelSerializer fallback in FixSerializedPKRelatedField.
  SerializedPKRelatedField.to_representation() passes nested unconditionally, so a
  serializer which doesn't accept it raises TypeError on every read; the branch
  documented a component for a configuration the API cannot serve.
* Generate the OpenAPI schema once per class rather than once per test method.
* Exercise the component.ref and request-schema return paths, and use SimpleTestCase
  for the tests which don't touch the database.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-28 15:36:42 -04:00
Jeremy Stretch 2893928662 Closes #22989: Reference brief components for nested SerializedPKRelatedField
FixSerializedPKRelatedField passed the serializer class to resolve_serializer(),
which instantiates it with no arguments. The field's nested setting was therefore
lost, and the generated response schema referenced the complete component (with
the complete field set) even where the field renders a brief representation.

Resolve an instance carrying the field's nested setting instead. Request schemas
are unaffected and continue to accept integer primary keys.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-28 15:20:36 -04:00
Martin Hauser 2b54582cd7 fix(api): Discover nested prefetches for SerializedPKRelatedField
Teach _get_nested_serializer() to unwrap ManyRelatedField and resolve the
serializer configured on SerializedPKRelatedField. Preserve the field's
nested value so prefetch discovery follows brief_fields for nested
representations and the full field set otherwise.

Guard the recursion against reference cycles by tracking the serializer
states already being resolved on the current path. Because nested defaults
to False the target expands its full field set, so a self-referential or
mutually referential declaration would otherwise recurse without a
termination condition. The key pairs the serializer class with its
effective field set, since re-entering a serializer at a narrower depth is
finite rather than cyclic, and the states are copied per frame so a sibling
field can still expand what another one stops at.

Populate interface VDC relationships and VRF route target assignments in
the API test fixtures, update the two query count baselines, and add
coverage for direct, many-valued and non-nested serialized related fields
alongside self-referential, mutually referential, brief-depth and
sibling-reuse cases.

Fixes #22988
2026-08-28 13:36:13 -04:00
Martin Hauser ab9bd6f5b6
Closes #23049: Update development database scripts for PostgreSQL 15 and later (#23065)
Fixes #23049
2026-08-28 10:43:52 -05:00