dnsimple-python
dnsimple-python copied to clipboard
ZoneRecordInput omits empty name when serialized to json
Hey, when trying to create a record at the apex I get a 400:
Reason: Bad Request
HTTP response body: {"message":"Validation failed","errors":{"name":["can't be null"]}}
Here is the code:
record = ZoneRecordInput(name="", type="CAA", ttl=60, content='0 issuewild "sectigo.com"')
client.zones.create_record(
account_id,
"example.com",
record,
)
The to_json() function removes empty fields and thus removed the name. However this field is required when using create_record making it impossible to create an apex level record.
Thanks for pointing this out, @jocelynthode. We'll have a look!
Sorry for the slow response @jocelynthode.
For more context on why we haven't moved ahead on this yet, even though it seems simple on the surface:
If we get rid of omitempty, updating a record would zero out the record name while updating the content (if name is not supplied). To fix this would be a change of behaviour and points to an underlying design flaw in the current implementation. It would be preferable for us to require the entire hostname, instead of the smaller name attribute.
This doesn't seem to be fixed yet, and affects ansible's dnsimple too.
Any workaround? You could at least allow a special symbol (say -) on your server which would make the string not empty and thus make everything work.