OpenAPI Model error for Interface Traces #10774

Closed
opened 2025-12-29 21:35:48 +01:00 by adam · 3 comments
Owner

Originally created by @jakeb91 on GitHub (Feb 19, 2025).

Deployment Type

Self-hosted

NetBox Version

v4.1.4

Python Version

3.11

Steps to Reproduce

  • Use or generate any v4 version of the go-netbox client generated from the Netbox OpenAPI specification to make a GET request against /api/dcim/interfaces/{id}/trace/ with the client.

This issue has already been raised on the go-netbox repository, the maintainer has suggested to raise the issue upstream as the bug is due to an error in the OpenAPI specification - see here for full debug information and testing: https://github.com/netbox-community/go-netbox/issues/198

Expected Behavior

Netbox returns a response that matches the OpenAPI specification.

Observed Behavior

Netbox returns a response that does not match the OpenAPI specification, resulting in a type error when parsing the response in generated OpenAPI clients.

The go-netbox client returns the following error message: json: cannot unmarshal array into Go value of type map[string]interface {} 

Below is the OpenAPI schema in question:

"/api/dcim/interfaces/{id}/trace/": {
    "get": {
        "operationId": "dcim_interfaces_trace_retrieve",
        "description": "Trace a complete cable path and return each segment as a three-tuple of (termination, cable, termination).",
        "parameters": [
            {
                "in": "path",
                "name": "id",
                "schema": {
                    "type": "integer"
                },
                "description": "A unique integer value identifying this interface.",
                "required": true
            }
        ],
        "tags": [
            "dcim"
        ],
        "security": [
            {
                "cookieAuth": []
            },
            {
                "tokenAuth": []
            }
        ],
        "responses": {
            "200": {
                "content": {
                    "application/json": {
                        "schema": {
                            "$ref": "#/components/schemas/Interface" <<< Netbox is not returning this data type as a response
                        }
                    }
                },
                "description": ""
            }
        }
    }
},

Example of the data Netbox is actually returning (domain names and provider names have been sanitised from this output):

HTTP 200 OK
Allow: GET, HEAD, OPTIONS, TRACE
Content-Type: application/json
Vary: Accept

[
    [
        [
            {
                "id": 5621,
                "url": "https://netbox.test/api/dcim/interfaces/5621/",
                "display": "Et9/1 (9)",
                "device": {
                    "id": 194,
                    "url": "https://netbox.test/api/dcim/devices/194/",
                    "display": "agg01.bri01",
                    "name": "agg01.bri01",
                    "description": ""
                },
                "name": "Et9/1",
                "description": "QSFP+ LR4 - Reserved for Provider1 NNI",
                "cable": {
                    "id": 707,
                    "url": "https://netbox.test/api/dcim/cables/707/",
                    "display": "#707",
                    "label": "",
                    "description": ""
                },
                "_occupied": true
            }
        ],
        {
            "id": 707,
            "url": "https://netbox.test/api/dcim/cables/707/",
            "display_url": "https://netbox.test/dcim/cables/707/",
            "type": "smf",
            "status": "connected",
            "label": "",
            "color": "ffeb3b",
            "length": null,
            "length_unit": "",
            "description": ""
        },
        [
            {
                "id": 348,
                "url": "https://netbox.test/api/dcim/front-ports/348/",
                "display": "F42A3-5/6",
                "device": {
                    "id": 199,
                    "url": "https://netbox.test/api/dcim/devices/199/",
                    "display": "a3.fpp01.bri01",
                    "name": "a3.fpp01.bri01",
                    "description": ""
                },
                "name": "F42A3-5/6",
                "description": "",
                "cable": {
                    "id": 707,
                    "url": "https://netbox.test/api/dcim/cables/707/",
                    "display": "#707",
                    "label": "",
                    "description": ""
                },
                "_occupied": true
            }
        ]
    ],
    [
        [
            {
                "id": 348,
                "url": "https://netbox.test/api/dcim/rear-ports/348/",
                "display": "F42A3-5/6",
                "device": {
                    "id": 199,
                    "url": "https://netbox.test/api/dcim/devices/199/",
                    "display": "a3.fpp01.bri01",
                    "name": "a3.fpp01.bri01",
                    "description": ""
                },
                "name": "F42A3-5/6",
                "description": "",
                "cable": {
                    "id": 854,
                    "url": "https://netbox.test/api/dcim/cables/854/",
                    "display": "#854",
                    "label": "",
                    "description": ""
                },
                "_occupied": true
            }
        ],
        {
            "id": 854,
            "url": "https://netbox.test/api/dcim/cables/854/",
            "display_url": "https://netbox.test/dcim/cables/854/",
            "type": "smf",
            "status": "connected",
            "label": "",
            "color": "ffeb3b",
            "length": null,
            "length_unit": "",
            "description": ""
        },
        [
            {
                "id": 160,
                "url": "https://netbox.test/api/circuits/circuit-terminations/160/",
                "display": "SID519109: Termination A",
                "circuit": {
                    "id": 411,
                    "url": "https://netbox.test/api/circuits/circuits/411/",
                    "display": "SID519109",
                    "cid": "SID519109",
                    "provider": {
                        "id": 11,
                        "url": "https://netbox.test/api/circuits/providers/11/",
                        "display": "Provider1",
                        "name": "Provider1",
                        "slug": "Provider1",
                        "description": ""
                    },
                    "description": "NNI"
                },
                "term_side": "A",
                "description": "",
                "cable": {
                    "id": 854,
                    "url": "https://netbox.test/api/dcim/cables/854/",
                    "display": "#854",
                    "label": "",
                    "description": ""
                },
                "_occupied": true
            }
        ]
    ],
    [
        [
            {
                "id": 161,
                "url": "https://netbox.test/api/circuits/circuit-terminations/161/",
                "display": "SID519109: Termination Z",
                "circuit": {
                    "id": 411,
                    "url": "https://netbox.test/api/circuits/circuits/411/",
                    "display": "SID519109",
                    "cid": "SID519109",
                    "provider": {
                        "id": 11,
                        "url": "https://netbox.test/api/circuits/providers/11/",
                        "display": "Provider1",
                        "name": "Provider1",
                        "slug": "Provider1",
                        "description": ""
                    },
                    "description": "NNI"
                },
                "term_side": "Z",
                "description": "",
                "cable": null,
                "_occupied": true
            }
        ],
        [],
        [
            {
                "id": 20,
                "url": "https://netbox.test/api/circuits/provider-networks/20/",
                "display": "NNI",
                "name": "NNI",
                "description": ""
            }
        ]
    ]
]
Originally created by @jakeb91 on GitHub (Feb 19, 2025). ### Deployment Type Self-hosted ### NetBox Version v4.1.4 ### Python Version 3.11 ### Steps to Reproduce - Use or generate any `v4` version of the go-netbox client generated from the Netbox OpenAPI specification to make a `GET` request against `/api/dcim/interfaces/{id}/trace/` with the client. This issue has already been raised on the `go-netbox` repository, the maintainer has suggested to raise the issue upstream as the bug is due to an error in the OpenAPI specification - see here for full debug information and testing: https://github.com/netbox-community/go-netbox/issues/198 ### Expected Behavior Netbox returns a response that matches the OpenAPI specification. ### Observed Behavior Netbox returns a response that does not match the OpenAPI specification, resulting in a type error when parsing the response in generated OpenAPI clients. The go-netbox client returns the following error message: `json: cannot unmarshal array into Go value of type map[string]interface {}`  Below is the OpenAPI schema in question: ```json "/api/dcim/interfaces/{id}/trace/": { "get": { "operationId": "dcim_interfaces_trace_retrieve", "description": "Trace a complete cable path and return each segment as a three-tuple of (termination, cable, termination).", "parameters": [ { "in": "path", "name": "id", "schema": { "type": "integer" }, "description": "A unique integer value identifying this interface.", "required": true } ], "tags": [ "dcim" ], "security": [ { "cookieAuth": [] }, { "tokenAuth": [] } ], "responses": { "200": { "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Interface" <<< Netbox is not returning this data type as a response } } }, "description": "" } } } }, ``` Example of the data Netbox is actually returning (domain names and provider names have been sanitised from this output): ```json HTTP 200 OK Allow: GET, HEAD, OPTIONS, TRACE Content-Type: application/json Vary: Accept [ [ [ { "id": 5621, "url": "https://netbox.test/api/dcim/interfaces/5621/", "display": "Et9/1 (9)", "device": { "id": 194, "url": "https://netbox.test/api/dcim/devices/194/", "display": "agg01.bri01", "name": "agg01.bri01", "description": "" }, "name": "Et9/1", "description": "QSFP+ LR4 - Reserved for Provider1 NNI", "cable": { "id": 707, "url": "https://netbox.test/api/dcim/cables/707/", "display": "#707", "label": "", "description": "" }, "_occupied": true } ], { "id": 707, "url": "https://netbox.test/api/dcim/cables/707/", "display_url": "https://netbox.test/dcim/cables/707/", "type": "smf", "status": "connected", "label": "", "color": "ffeb3b", "length": null, "length_unit": "", "description": "" }, [ { "id": 348, "url": "https://netbox.test/api/dcim/front-ports/348/", "display": "F42A3-5/6", "device": { "id": 199, "url": "https://netbox.test/api/dcim/devices/199/", "display": "a3.fpp01.bri01", "name": "a3.fpp01.bri01", "description": "" }, "name": "F42A3-5/6", "description": "", "cable": { "id": 707, "url": "https://netbox.test/api/dcim/cables/707/", "display": "#707", "label": "", "description": "" }, "_occupied": true } ] ], [ [ { "id": 348, "url": "https://netbox.test/api/dcim/rear-ports/348/", "display": "F42A3-5/6", "device": { "id": 199, "url": "https://netbox.test/api/dcim/devices/199/", "display": "a3.fpp01.bri01", "name": "a3.fpp01.bri01", "description": "" }, "name": "F42A3-5/6", "description": "", "cable": { "id": 854, "url": "https://netbox.test/api/dcim/cables/854/", "display": "#854", "label": "", "description": "" }, "_occupied": true } ], { "id": 854, "url": "https://netbox.test/api/dcim/cables/854/", "display_url": "https://netbox.test/dcim/cables/854/", "type": "smf", "status": "connected", "label": "", "color": "ffeb3b", "length": null, "length_unit": "", "description": "" }, [ { "id": 160, "url": "https://netbox.test/api/circuits/circuit-terminations/160/", "display": "SID519109: Termination A", "circuit": { "id": 411, "url": "https://netbox.test/api/circuits/circuits/411/", "display": "SID519109", "cid": "SID519109", "provider": { "id": 11, "url": "https://netbox.test/api/circuits/providers/11/", "display": "Provider1", "name": "Provider1", "slug": "Provider1", "description": "" }, "description": "NNI" }, "term_side": "A", "description": "", "cable": { "id": 854, "url": "https://netbox.test/api/dcim/cables/854/", "display": "#854", "label": "", "description": "" }, "_occupied": true } ] ], [ [ { "id": 161, "url": "https://netbox.test/api/circuits/circuit-terminations/161/", "display": "SID519109: Termination Z", "circuit": { "id": 411, "url": "https://netbox.test/api/circuits/circuits/411/", "display": "SID519109", "cid": "SID519109", "provider": { "id": 11, "url": "https://netbox.test/api/circuits/providers/11/", "display": "Provider1", "name": "Provider1", "slug": "Provider1", "description": "" }, "description": "NNI" }, "term_side": "Z", "description": "", "cable": null, "_occupied": true } ], [], [ { "id": 20, "url": "https://netbox.test/api/circuits/provider-networks/20/", "display": "NNI", "name": "NNI", "description": "" } ] ] ] ```
adam added the type: bugstatus: needs ownerpending closureseverity: low labels 2025-12-29 21:35:48 +01:00
adam closed this issue 2025-12-29 21:35:48 +01:00
Author
Owner

@arthanson commented on GitHub (Feb 21, 2025):

potentially looks like a spectacular decorator is needed on dcim.api.views.PathEndpointMixin

@arthanson commented on GitHub (Feb 21, 2025): potentially looks like a spectacular decorator is needed on dcim.api.views.PathEndpointMixin
Author
Owner

@github-actions[bot] commented on GitHub (May 23, 2025):

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. Do not attempt to circumvent this process by "bumping" the issue; doing so will result in its immediate closure and you may be barred from participating in any future discussions. Please see our contributing guide.

@github-actions[bot] commented on GitHub (May 23, 2025): This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. **Do not** attempt to circumvent this process by "bumping" the issue; doing so will result in its immediate closure and you may be barred from participating in any future discussions. Please see our [contributing guide](https://github.com/netbox-community/netbox/blob/main/CONTRIBUTING.md).
Author
Owner

@github-actions[bot] commented on GitHub (Jun 22, 2025):

This issue has been automatically closed due to lack of activity. In an effort to reduce noise, please do not comment any further. Note that the core maintainers may elect to reopen this issue at a later date if deemed necessary.

@github-actions[bot] commented on GitHub (Jun 22, 2025): This issue has been automatically closed due to lack of activity. In an effort to reduce noise, please do not comment any further. Note that the core maintainers may elect to reopen this issue at a later date if deemed necessary.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#10774