-
Notifications
You must be signed in to change notification settings - Fork 158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Creating Manufacture errors out because of missing required property devicetype_count #165
Comments
As the manufacturer is created, this is likely to be a deserialization error from the API response rather than a server error during the creation. Could you mention what version Netbox you're using? Sadly, Netbox does not offer much in the way of API stability guarantees, and Netbox clients versions need to remain tightly coupled with the server version, otherwise this kind of error is likely to show up. |
Yes, 3.7.1 after it was created with goswagger. It also happens to generate DeviceType, DeviceRole, and Site. In line 107803 of the |
Does In my case, the API returns 201 and the manufacturer is still created in netbox, so I just bypass that error for now. |
I don't know. CodeCode from openapi.yaml Manufacturer:
type: object
description: Adds support for custom fields and tags.
properties:
id:
type: integer
readOnly: true
url:
type: string
format: uri
readOnly: true
display:
type: string
readOnly: true
name:
type: string
maxLength: 100
slug:
type: string
maxLength: 100
pattern: ^[-a-zA-Z0-9_]+$
description:
type: string
maxLength: 200
tags:
type: array
items:
$ref: '#/components/schemas/NestedTag'
custom_fields:
type: object
additionalProperties: {}
created:
type: string
format: date-time
readOnly: true
nullable: true
last_updated:
type: string
format: date-time
readOnly: true
nullable: true
devicetype_count:
type: integer
readOnly: true
inventoryitem_count:
type: integer
readOnly: true
platform_count:
type: integer
readOnly: true
required:
- created
- devicetype_count
- display
- id
- inventoryitem_count
- last_updated
- name
- platform_count
- slug
- url
ManufacturerRequest:
type: object
description: Adds support for custom fields and tags.
properties:
name:
type: string
minLength: 1
maxLength: 100
slug:
type: string
minLength: 1
maxLength: 100
pattern: ^[-a-zA-Z0-9_]+$
description:
type: string
maxLength: 200
tags:
type: array
items:
$ref: '#/components/schemas/NestedTagRequest'
custom_fields:
type: object
additionalProperties: {}
required:
- name
- slug The |
I had some time to look into this issue this morning, and managed to reproduce it creating a device role with a Netbox 3.7.3 server and the current alpha release of the client (v3.7.1-alpha.0). Reproduction code is as follows: req := netbox.NewWritableDeviceRoleRequestWithDefaults()
req.SetName("test-role")
req.SetSlug("test-role")
result, resp, err := c.Netbox.
DcimAPI.
DcimDeviceRolesCreate(ctx).
WritableDeviceRoleRequest(*req).
Execute() The error returned is The list of broken endpoints this far is as follows:
I found a similar issue on the Netbox project for the |
Upstream issue is now closed and released as part of 4.0.3 |
In my case it may be due to the older version of netbox being used, I downgraded to |
Yeah is affecting everything endpoint or resource I have tried so far. |
Still have the issue when creating device roles: roleRequest := netbox.NewDeviceRoleRequest("Default device role", "default")
req := r.client.DcimAPI.DcimDeviceRolesCreate(ctx)
req = req.DeviceRoleRequest(roleRequest)
created, _, err = req.Execute() yields error "no value given for required property device_count" Client version: v4.0.3-0 When calling the Server API manually (POST /api/dcim/device-roles/), I can see that there is no EDIT: Minimal example to reproduce the error: _, _, err := client.DcimAPI.DcimDeviceTypesList(context.Background()).Execute() yields error "no value given for required property devicetype_count" The failure reason in this case is that the device type list includes a manufacturer model for each device type model, but the manufacturer model does not contain the full manufacturer data; in particular, it misses the |
The reason this problem exists, even with the latest version, is due to the following generated code: func (o *BriefManufacturer) UnmarshalJSON(data []byte) (err error) {
// This validates that all required properties are included in the JSON object
// by unmarshalling the object into a generic map with string keys and checking
// that every required field exists as a key in the generic map.
requiredProperties := []string{
"id",
"url",
"display",
"name",
"slug",
"devicetype_count",
} If you remove "manufacturer": {
"id": 47,
"url": "https://netbox.xxx.com/api/dcim/manufacturers/47/",
"display": "A10",
"name": "A10",
"slug": "a10",
"description": ""
},
Note |
I'm trying to create a manufacturer like this:
I get this error:
I can see how devicetype_count is required for a Manufacturer but not for a ManafacturerRequest. At the same time, the Manufacture is created, but the
Execute
returns an error.The text was updated successfully, but these errors were encountered: