dnsimple-python icon indicating copy to clipboard operation
dnsimple-python copied to clipboard

ZoneRecordInput omits empty name when serialized to json

Open jocelynthode opened this issue 1 year ago • 1 comments

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.

jocelynthode avatar Jul 03 '24 08:07 jocelynthode

Thanks for pointing this out, @jocelynthode. We'll have a look!

dallasread avatar Jul 19 '24 13:07 dallasread

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.

dallasread avatar Dec 13 '24 14:12 dallasread

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.

albertca avatar Jul 10 '25 23:07 albertca