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

Unexpected error return from IpamPrefixesList #177

Open
tgoodsell-tempus opened this issue Jun 4, 2024 · 1 comment
Open

Unexpected error return from IpamPrefixesList #177

tgoodsell-tempus opened this issue Jun 4, 2024 · 1 comment

Comments

@tgoodsell-tempus
Copy link

When running the following function:

package main

import (
	"context"
	"log"
	"os"

	"github.com/netbox-community/go-netbox/v4"
)

func main() {
	ctx := context.Background()

	client := netbox.NewAPIClientFor("https://netbox.zro.gcp.tempus.cloud", os.Getenv("NETBOX_API_TOKEN"))

	prefixList, resp, err := client.IpamAPI.IpamPrefixesList(ctx).Execute()
	if err != nil {
		log.Printf("Num returned: %d", len(prefixList.Results))
		log.Printf("HTTP RESP: %v", resp)
		log.Fatalf("Failed to get prefixes: %v", err)
	}
}

I'm seeing results where:

  • preflxList has no results
  • RESP is a 200 return with the expected prefix outputs in the JSON body
  • The value of the err returned is: no value given for required property prefix_count

Netbox version being run: v4.0.3

Based on the value of the response, I gather this is an issue with the parsing of this request, rather than an actual API issue.

@vlaborie
Copy link

I have the same problem with IpamIpRangesList and no value given for required property prefix_count.

I think the error in on the response parsing, role.prefix_count in my case (vrf.prefix_count in your's) is marked as required in OpenAPI spec but are not returned by the API:

GET /api/ipam/ip-ranges/?status=active

HTTP 200 OK
Allow: GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "count": 1,
    "next": null,
    "previous": null,
    "results": [
        {
            "id": 1,
            "url": "https://demo.netbox.dev/api/ipam/ip-ranges/1/",
            "display_url": "https://demo.netbox.dev/ipam/ip-ranges/1/",
            "display": "192.168.1.0-49/22",
            "family": {
                "value": 4,
                "label": "IPv4"
            },
            "start_address": "192.168.1.0/22",
            "end_address": "192.168.1.49/22",
            "size": 50,
            "vrf": null,
            "tenant": null,
            "status": {
                "value": "active",
                "label": "Actif"
            },
            "role": {
                "id": 5,
                "url": "https://demo.netbox.dev/api/ipam/roles/5/",
                "display": "Testing",
                "name": "Testing",
                "slug": "testing",
                "description": ""
            },
            "description": "Future use",
            "comments": "",
            "tags": [],
            "custom_fields": {},
            "created": "2021-12-30T00:00:00Z",
            "last_updated": "2024-10-25T11:11:26.071302Z",
            "mark_utilized": false
        }
    ]
}

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

No branches or pull requests

2 participants