Skip to content

Netbox tag requiring tagged_items on unmarshal while the API doesn't return that information #205

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

Closed
greatman opened this issue Feb 27, 2025 · 3 comments

Comments

@greatman
Copy link
Contributor

greatman commented Feb 27, 2025

Hello!

https://github.com/netbox-community/go-netbox/blob/master/model_tag.go#L478

The UnmarshalJSON method requires the tagged_items property in the JSON from netbox. When creating an object, that field is not shown:

{
  "id" : 10,
  "url" : "http://localhost:8001/api/extras/tags/10/",
  "display_url" : "http://localhost:8001/extras/tags/10/",
  "display" : "test-tag_basic-vu6hw8lmkf",
  "name" : "test-tag_basic-vu6hw8lmkf",
  "slug" : "test-tag_basic-2xheda2ay7",
  "color" : "112233",
  "description" : "This is a test",
  "object_types" : [ ],
  "created" : "2025-02-27T15:00:25.402848Z",
  "last_updated" : "2025-02-27T15:00:25.402859Z"
}

I used the following to create a tag:

api_res, _, err := client.ExtrasAPI.
		ExtrasTagsCreate(ctx).
		TagRequest(*tagRequest).Execute()
@greatman
Copy link
Contributor Author

Actually, just noticed my netbox test instance is not 4.2+, gonna test on that to see if it's still the same.

@greatman
Copy link
Contributor Author

Still does that in v4.2.2.

@nutgood
Copy link
Collaborator

nutgood commented Feb 27, 2025

I'm a little busy but I'll get a release out tomorrow that fixes this.

Otherwise, you can edit model_tag.go directly as well as add the prop name here and open a PR and I'll merge and release v4.2.2-3 with your changes today.

nutgood added a commit that referenced this issue Feb 28, 2025
Fixes #205: Removes tagged_items from required properties for Tags.
nutgood added a commit that referenced this issue Feb 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants