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

Nullable fields not nullable in the OpenAPI spec #15588

Closed
fbs opened this issue Mar 30, 2024 · 3 comments · Fixed by #15768
Closed

Nullable fields not nullable in the OpenAPI spec #15588

fbs opened this issue Mar 30, 2024 · 3 comments · Fixed by #15768
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

@fbs
Copy link

fbs commented Mar 30, 2024

Deployment Type

Self-hosted

NetBox Version

v3.7.4

Python Version

3.11

Steps to Reproduce

Compare the API spec on dcim/devices to the actual API response

Expected Behavior

An unknown number of fields should be marked nullable in the openapi spec

This include at least:

  • primary_ip on VirtualMachineWithConfigContext
  • primary_ip on DeviceWithConfigContext

I think there are more as I expect this an issue with how the spec is generated from properties

Observed Behavior

$ curl -s -X 'GET' 'http://localhost:9876/api/dcim/devices/?name=NAME' -H 'accept: application/json' -H 'Authorization: token KEY' | jq '.results[0]|[.role, .primary_ip, .primary_ip4 ]'
[
  {
    "id": 15,
    "url": "http://localhost:9876/api/dcim/device-roles/15/",
    "display": "Server",
    "name": "Server",
    "slug": "server"
  },
  null, # <- primary_ip
  null  # <- primary_ip4
]

compared to the spec:

$ curl -s http://localhost:9876/api/schema/ | yq '.components.schemas.VirtualMachineWithConfigContext.properties.primary_ip'
allOf:
  - $ref: '#/components/schemas/NestedIPAddress'
readOnly: true

Note how primary_ipv4 is marked nullable, as expected

$ curl -s http://localhost:9876/api/schema/ | yq '.components.schemas.VirtualMachineWithConfigContext.properties.primary_ip4'
allOf:
  - $ref: '#/components/schemas/NestedIPAddress'
nullable: true

The above is just one instance, it happens to other schemas as well. E.g. DeviceWithConfigContext has the same problem

@fbs fbs added status: needs triage This issue is awaiting triage by a maintainer type: bug A confirmed report of unexpected behavior in the application labels Mar 30, 2024
@fbs
Copy link
Author

fbs commented Mar 30, 2024

My guess would be that this comes from the primary_ip being a property, making it read only but not nullable. But I'm not sure whether thats in the right direction.

I'd be open to fixing this but will need some pointers

@jeremystretch
Copy link
Member

These fields should be nullable

Please spend some more time on your report. Without an explicit list of fields which you believe to be erroneously defined, this is not actionable.

@jeremystretch jeremystretch removed their assignment Apr 1, 2024
@jeremystretch jeremystretch added status: revisions needed This issue requires additional information to be actionable and removed status: needs triage This issue is awaiting triage by a maintainer labels Apr 1, 2024
@fbs
Copy link
Author

fbs commented Apr 2, 2024

These fields should be nullable

Please spend some more time on your report. Without an explicit list of fields which you believe to be erroneously defined, this is not actionable.

Sorry, I've updated the issue description to list the fields I identified.

I think we can identify all fields impacted when we understand what is causing the spec for these to be wrong

@jeremystretch jeremystretch added status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation topic: OpenAPI severity: low Does not significantly disrupt application functionality, or a workaround is available and removed status: revisions needed This issue requires additional information to be actionable labels Apr 2, 2024
@arthanson arthanson self-assigned this Apr 18, 2024
@arthanson arthanson removed the status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation label Apr 18, 2024
@jeremystretch jeremystretch added the status: accepted This issue has been accepted for implementation label Apr 19, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 19, 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