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

Package incompatible with NetBox v3.2.0 #127

Closed
nleiva opened this issue Apr 8, 2022 · 2 comments
Closed

Package incompatible with NetBox v3.2.0 #127

nleiva opened this issue Apr 8, 2022 · 2 comments

Comments

@nleiva
Copy link

nleiva commented Apr 8, 2022

NetBox 3.2 introduced breaking changes that make this package incompatible: https://github.com/netbox-community/netbox/releases/tag/v3.2.0. This is because of a change in the created timestamp of the API.

The created field of all change-logged models now conveys a full datetime object, rather than only a date. (Previous date-only values will receive a timestamp of 00:00.) While this change is largely unconcerning, strictly-typed API consumers may need to be updated.

I run into this issue when using the Terraform NetBox provider: e-breuninger/terraform-provider-netbox#145.

I believe this is because go-netbox depends on strfmt v0.20.2, that defines RFC3339FullDate:

const (
	// RFC3339FullDate represents a full-date as specified by RFC3339
	// See: http://goo.gl/xXOvVd
	RFC3339FullDate = "2006-01-02"
)

https://github.com/go-openapi/strfmt/blob/v0.20.2/date.go#L39-L43

To parse instances of "date".

  case "date":
	  d, err := time.Parse(RFC3339FullDate, data.(string))
	  if err != nil {
		  return nil, err
	  }

https://github.com/go-openapi/strfmt/blob/v0.20.2/format.go#L105-L109

Which is what they use to parse the created responses. So it only expects a date.

func (m *Platform) validateCreated(formats strfmt.Registry) error {
	if swag.IsZero(m.Created) { // not required
		return nil
	}

	if err := validate.FormatOf("created", "body", "date", m.Created.String(), formats); err != nil {
		return err
	}

	return nil
}

I reproduced this error in the Go playground -> https://go.dev/play/p/Kybi_Kguigf.

Thanks.

@wfyanmnm
Copy link

@nleiva I am not femilliar with go lang, is there a quick way to fix it on code level?

@v0ctor
Copy link
Collaborator

v0ctor commented Apr 25, 2022

This issue has been fixed in the latest release. It may be closed. 🎉

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

4 participants