Skip to content
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

Incorrect Field Type in Response for GET /api/dcim/device-type(/{id}/) Model Schema #15184

Closed
jniec-js opened this issue Feb 17, 2024 · 4 comments · Fixed by #15200
Closed

Incorrect Field Type in Response for GET /api/dcim/device-type(/{id}/) Model Schema #15184

jniec-js opened this issue Feb 17, 2024 · 4 comments · Fixed by #15200
Assignees
Labels
severity: low Does not significantly disrupt application functionality, or a workaround is available status: accepted This issue has been accepted for implementation topic: OpenAPI type: bug A confirmed report of unexpected behavior in the application

Comments

@jniec-js
Copy link

Deployment Type

Self-hosted

NetBox Version

v3.7.1

Python Version

3.11

Steps to Reproduce

  1. Look at the API documentation for /api/dcim/device-types/{id}, on the demo site (https://demo.netbox.dev/api/schema/swagger-ui/#/dcim/dcim_device_types_retrieve) and inspect the Schema for DeviceType, see that front_image and rear_image are declared as strings
  2. Use https://demo.netbox.dev/dcim/device-types/7/ as an example to test, a device_type that has no front or rear images associated with the object
  3. Send an http GET request to /api/dcim/device-types/7/ using the netbox demo's swagger documentation website here: https://demo.netbox.dev/api/schema/swagger-ui/#/dcim/dcim_device_types_retrieve, click "try it out!", for the ID, enter in 7, click Execute
  4. Observe that the response payload for front_image and/or rear_image is set to null and not an empty string despite the Model specifying "string" for the type and not specfying "nullable:true" on the field. See screenshots below:

Expected Behavior

I expected that the types in the response from the query would match what types are defined in the model.

Observed Behavior

We get back the wrong type in the response from the API when a front and/or rear image is not attached to a device_type.
Screenshot from 2024-02-16 21-12-05
Screenshot from 2024-02-16 21-11-55

@jniec-js jniec-js added the type: bug A confirmed report of unexpected behavior in the application label Feb 17, 2024
@jeremystretch
Copy link
Member

I expected that the types in the response from the query would match what types are defined in the model.

Please specify exactly what you expect to see in the specification for the field.

@jeremystretch jeremystretch added the status: revisions needed This issue requires additional information to be actionable label Feb 20, 2024
@jniec-js
Copy link
Author

I would expect that the specification either say "nullable: true" or the response be an empty string for both fields.

@jeremystretch
Copy link
Member

Can you point to an example of this elsewhere in the spec?

@jniec-js
Copy link
Author

I see other fields in the same model as marked 'nullable: true'. Though these are objects, I am unsure if that matters for this or not though.

Screenshot from 2024-02-20 10-49-59

@jeremystretch jeremystretch added status: accepted This issue has been accepted for implementation severity: low Does not significantly disrupt application functionality, or a workaround is available status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation and removed status: revisions needed This issue requires additional information to be actionable status: accepted This issue has been accepted for implementation labels Feb 20, 2024
@abhi1693 abhi1693 added status: accepted This issue has been accepted for implementation and removed status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation labels Feb 20, 2024
@abhi1693 abhi1693 self-assigned this Feb 20, 2024
jeremystretch pushed a commit that referenced this issue Feb 20, 2024
* added allow_null for front and rear image on api #15184

* added allow_null for front and rear image on api #15184
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
severity: low Does not significantly disrupt application functionality, or a workaround is available status: accepted This issue has been accepted for implementation topic: OpenAPI type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants