UNIFI: fix errors on version 10.2.105#4201
UNIFI: fix errors on version 10.2.105#4201Matthew-Kilpatrick wants to merge 1 commit intoDNSControl:mainfrom
Conversation
|
Thank you for sending this! Right now the project is in transition but I hope to be able to address this once we've moved to our new git org. |
c2eec88 to
0439ce6
Compare
A number of issues with request payloads resulted in errors from some
Unifi Network versions (eg. 10.2.105), which this commit addresses:
- The `metadata` field is documented as read-only, and so when this
provider included this field in the request payload, the error
`Unknown request body property '$.metadata' was returned
- The `id` being passed in payloads for updates caused issues
(`Unknown request body property '$.id'`), as this is an undocumented
field which is provided in the path.
- The omission of the `ttlSeconds` field (which was the case for the
default 300 value) resulted in `ttlSeconds must not be null`
- The provider previously made a single `GET `/v1/sites/{siteId}/dns/policies`
request to check the current state, however, a default page-size limit of 25
records and lack of pagination could miss records and result in
`DNS policy with the same type and properties already exists` errors
7ad1941 to
61eaa0a
Compare
|
Thanks @Matthew-Kilpatrick for tracking this down and writing it up so cleanly, the reproduction logs in the description made it trivial to verify. I ran the current
All four server-side changes you pinned down line up with what I see on v10.2.105: unknown-property rejection is now strict, Nice work, and thanks again I really love open source! 😀 |
|
Thank you for sending this! Right now the project is in transition but I hope to be able to address this once we've moved to our new git org. |
When using the Unifi provider with Unifi Network 10.2.105, a number of errors cause DNSControl to fail to apply changes.
Metadata in payload
Looking over the documentation at https://developer.ui.com/network/v10.1.84/creatednspolicy, it seems the
metadatafield this provider was attempting to write to is documented as read-only.This PR updates the provider to no longer set the
metadatafield when making requests to the API:ID in payload
The ID was provided in the path (as expected), but also the request payload, which Unifi's validation did not like.
Omitted TTL
The documentation on the Unifi site doesn't list this field as required so I'm somewhat confused by this, however, the provider omitted this field for a value of 300s, and this resulted in the following error:
I don't see any harm including it even if it matches the default (if anything, I think it's a marginal improvement - in the event unifi changed defaults, the config from DNSControl should be the source of truth).
Record pagination
When checking existing DNS record state, the existing implementation made a single call to
GET/v1/sites/{siteId}/dns/policies`. This had a default limit of 25 records, so could cause errors when re-creating existing records:I've updated this to paginate results to ensure all records are fetched.