-
Notifications
You must be signed in to change notification settings - Fork 24
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
UpdateRecord requires Name field #33
Comments
@Ulexus the I'm pretty sure it also worked for the updates at the time we tried, but indeed it seems to be a reasonable issue that I also pointed out at the time of #16. We'll try to find a solution. |
I, too, think it worked originally. I had code out that suddenly stopped working at some point a few months ago, and I finally had time to track it down to this. I don't think there is anything wrong with this compromise; I would just at least document it, since the requirement varies from the API spec. For my case, I was already calling GetRecord() first, anyway, so I just added the Name field to the update... I just needed to know that was required. |
Closed by #92 |
A ZoneRecord name can be an empty value `""`. This is because our API mimic the UI and it requires the consumer to specify the zone record name without the zone, in other words not the qualified name. As a result, when the qualified name also matches the zone name (for apex), the value of name is blank: ``` zone: example record: www.example.com -> name: "www" zone: example record: example.com -> name: "" ``` In Go, there is no way to distinguish a non-present string (null) vs a blank string. That's because [the zero value](https://tour.golang.org/basics/12) of a string type is an empty string. I decided to not change the signature of ZoneRecord but instead supply a different type of record attributes. This is actually another quite common pattern for particularly complex requests, and we also use in the [Registrar](https://github.com/dnsimple/dnsimple-go/blob/master/dnsimple/registrar.go#L134) where we supply special input structs to handle the payload of the registrar calls. This time I went with `-Attributes` and not `-Input` as there is a direct relationship between this struct at the zone record attributes, as well the zone record struct. Fixes #33
The
Name
field ofZoneRecord
does not haveomitempty
set on its tag, so it sends it even if it is empty, which causes the server to respond with400 Validation failed
.The simple workaround is to always supply the
Name
field in theZoneRecord
, but this does not agree with the API documentation.This should either be documented with
UpdateRecord
or haveZoneRecord
updated to make theName
field tagged withomitempty
.The text was updated successfully, but these errors were encountered: