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

Terraform import of unifi_device returning error #136

Closed
alisonjenkins opened this issue Apr 13, 2021 · 10 comments
Closed

Terraform import of unifi_device returning error #136

alisonjenkins opened this issue Apr 13, 2021 · 10 comments
Labels
bug Something isn't working dependencies Pull requests that update a dependency file

Comments

@alisonjenkins
Copy link
Contributor

When importing a unifi_device I am receiving the following error:

terraform import unifi_device.office_switch 'f4:92:bf:8b:7b:65'
unifi_device.office_switch: Importing from ID "f4:92:bf:8b:7b:65"...

Error: unable to decode body: GET s/default/stat/device unable to unmarshal alias: unable to unmarshal alias: json: cannot unmarshal number into Go struct field .ht of type string

Do you have any advice on how to debug the response as this was previously working so I am wondering if this is due to an update of the Unifi Dream Machine's Network Management module.

@paultyng
Copy link
Owner

This may be a bug that was recently fixed in the SDK, hopefully will ship a new version shortly that fixes some of these marshalling issues.

Are you on the latest version of the provider?

@paultyng paultyng added bug Something isn't working dependencies Pull requests that update a dependency file labels Apr 16, 2021
@alisonjenkins
Copy link
Contributor Author

Hey Paul,

Yes I am on 0.26.0.

May I ask though... how do you find the API info and debug requests to the API at current? Do you use mitmproxy or something similar?

I am interested in helping to do some development on this provider (and also contemplating working on a Terraform provider of my own) so any advice on how to get started would be appreciated.

Thanks,

Alan Jenkins

@chrishas35
Copy link
Contributor

Confirmed this on 0.26.0 w/ UDM Pro Firmware 1.8.6 and Network 6.0.43.

@kradalby
Copy link

I am seeing a similar issue, just with .stp_priority on 6.2.26 on a self-hosted controller:

❯ terraform import unifi_device.love-loft 74:ac:b9:a8:d6:96
unifi_device.love-loft: Importing from ID "74:ac:b9:a8:d6:96"...

│ Error: unable to decode body: GET s/default/stat/device unable to unmarshal alias: json: cannot unmarshal number into Go struct field .stp_priority of type string

@evenh
Copy link

evenh commented Oct 30, 2022

I'm seeing the same issue as @kradalby, when planning:

│ Error: unable to decode body: GET s/default/stat/device unable to unmarshal alias: json: cannot unmarshal number into Go struct field .stp_priority of type string
│ 
│   with unifi_device.kjokken,
│   on aps.tf line 15, in resource "unifi_device" "kjokken":
│   15: resource "unifi_device" "kjokken" {

I've enabled STP under Networks in the GUI, and overridden the manual configuration for a switch. Reverting the change gives the same behaviour. Should it be changed to numberOrString here?

@paultyng
Copy link
Owner

@evenh I think you are correct, when I just inspected my traffic i saw "stp_priority": "32768"

@paultyng
Copy link
Owner

I'll do a quick update and regenerate the SDK and bump the version.

@paultyng
Copy link
Owner

This fix should go out in v0.38.2, I'm not 100% sure it will fix this, but worth a shot!

@paultyng
Copy link
Owner

If it doesn't fix it, just let me know here and I'll reopen it

@woneill
Copy link
Contributor

woneill commented Nov 2, 2022

Confirming this had been an issue and is now fixed in v0.38.2 w/ UDM Pro Firmware 1.12.30 and Network 7.2.94/7.2.95. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working dependencies Pull requests that update a dependency file
Projects
None yet
Development

No branches or pull requests

6 participants