Skip to content

Add Tenant field to AvailableIP model#56

Open
msollanych-tt wants to merge 5 commits into
fbreckle:masterfrom
msollanych-tt:master
Open

Add Tenant field to AvailableIP model#56
msollanych-tt wants to merge 5 commits into
fbreckle:masterfrom
msollanych-tt:master

Conversation

@msollanych-tt

Copy link
Copy Markdown

So basically my Netbox has a requirement for the Tenant field when you put in an IP address, and the current version was not setting it correctly; this is an AI slop-coded fix for the problem verified against my fork of terraform-provider-netbox that I'll be releasing in a bit; I don't intend or suggest to take over maintenance or anything like that, just need to get unblocked for some work projects here that use Netbox heavily. I unfortunately don't even speak Go, but hey, it's 2025; be harsh with your criticisms and I'll be happy to go feed them back into the AI for ya and spit out something better.

Hopefully this stuff can get rolled upstream and then I'll archive my forks; though I might have some more fixes for you in the future. Thanks for the work on this BTW!

  • Add Tenant field to AvailableIP model for terraform-provider-netbox issue #812
  • Fix tenant field type for WritableAvailableIP
  • Changed WritableAvailableIP.Tenant from NestedTenant to integer
  • Updated API operations to use WritableAvailableIP for request body
  • AvailableIP (read) still uses NestedTenant for full object representation
  • Fixes 400 error: 'Related object not found' when creating IPs with tenant

NetBox requires tenant_id when creating available IPs via the
prefixes and IP ranges endpoints. The upstream swagger spec doesn't
include this field, so we add it manually.

Changes:
- Add Tenant int64 field to WritableAvailableIP model
- Change IpamPrefixesAvailableIpsCreate params to use WritableAvailableIP
- Change IpamIPRangesAvailableIpsCreate params to use WritableAvailableIP

Based on upstream master (550476f) which includes render-config
endpoint and service parent_object fields.

Made-with: Cursor
msollanych-tt and others added 4 commits April 27, 2026 19:06
…d/module_type_id in dcim_*_templates list endpoints

The OpenAPI spec this client was generated from uses the legacy
`devicetype_id` / `moduletype_id` query parameter names for the
dcim_*_templates list endpoints. Modern NetBox (4.4+, possibly
earlier) renamed these to `device_type_id` and `module_type_id`,
matching the rest of the API.

Critically, NetBox **silently ignores** unknown query params on these
endpoints rather than rejecting them. So a list call with
`?devicetype_id=164` returns the unfiltered global list of templates
of that type, not the templates owned by device_type 164. Code paths
that use the result for reconciliation (e.g. terraform-provider-netbox
nested device_type templates feature) will then attempt to delete
templates that are not in their config, mass-corrupting NetBox.

Patches all 30 SetQueryParam call sites in 10 files:

  dcim_console_port_templates_list_parameters.go
  dcim_console_server_port_templates_list_parameters.go
  dcim_device_bay_templates_list_parameters.go
  dcim_front_port_templates_list_parameters.go
  dcim_interface_templates_list_parameters.go
  dcim_inventory_item_templates_list_parameters.go
  dcim_module_bay_templates_list_parameters.go
  dcim_power_outlet_templates_list_parameters.go
  dcim_power_port_templates_list_parameters.go
  dcim_rear_port_templates_list_parameters.go

Field types and `WithDevicetypeID` / `WithModuletypeID` Go method
names are deliberately left alone — only the wire-format query param
strings change. The Go-side API is identical; existing callers stay
source-compatible.

Verified against NetBox 4.4.10:
  ?devicetype_id=99999  -> 200, count=66 (silently ignored, returns all)
  ?device_type_id=99999 -> 400, "Select a valid choice." (correct)

Made-with: Cursor
fix: correct ui_visible JSON tag on WritableCustomField (was ui_visib…
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants