AnalogJ / lexicon

Manipulate DNS records on various DNS providers in a standardized way.
MIT License
1.48k stars 304 forks source link

`godaddy` provider fails under v3.3.24 given FDQN #518

Open eengstrom opened 4 years ago

eengstrom commented 4 years ago

Upon upgrading from 3.3.23 to .24, the godaddy provider fails when given a FQDN including a full stop. e.g. foo.example.com. (note trailing period). E.g.:

odin $ lexicon --version
lexicon 3.3.24

odin $ lexicon godaddy create example.com TXT --name=foo.example.com. --content=bar.example.com
Traceback [elided...]
requests.exceptions.HTTPError: 422 Client Error: Unprocessable Entity for url: https://api.godaddy.com/v1/domains/example.com/records/CNAME/foo.example.com.

odin $ pip3 install dns-lexicon==3.3.23
[elided...]
Successfully installed dns-lexicon-3.3.23

odin $ lexicon --version
lexicon 3.3.23

odin $ lexicon godaddy create example.com TXT --name=foo.example.com. --content=bar.example.com
RESULT
------
True

Looks like there have been a lot of changes recently, so I'm figuring this one is easy, but if @adferrand doesn't see the issue right away, LMK and I'll dive in and try to fix.

Seems like it's also related to #362, but until today I would have said that issue was OBE.

doddo commented 4 years ago

The breaking of this one seems to correlate with the addition of workarounds for zones with CAA records (#506) (which the API does not support)

curl -s  -X GET -H "Authorization: sso-key $SSO_KEY" "https://api.godaddy.com/v1/domains/fistofsteel.xyz/records/CAA"  | jq .
{
  "code": "INVALID_VALUE_ENUM",
  "message": "type not any of: A, AAAA, CNAME, MX, NS, SOA, SRV, TXT"
}

The error is here in the provider. name ought to be in the short form but it is not.

    self._put('/domains/{0}/records/{1}/{2}'.format(domain, rtype, name), records)

I stumbled across some other errors too, related to updates throwing 422 expecting a list of records, but getting a single record instead running the test suite after making the above adjustments, which I found a bit confusing as they did not relate to the bits of code which I changed.

Furthermore, the API does now seem to have envolved since the godaddy provider was created, I do believe that it could be simplified somewhat.

Maybe an overhaul of the whole thing could be a good idea?

adferrand commented 4 years ago

Hello!

Indeed, I think that replacing name with relative_name will fix issues. My bad, I missed this during the review of #506.

I just reactivated my domain on godaddy, hope I will be able to resync the test suite and provide a fix in the next hours.

adferrand commented 4 years ago

OK. Too much errors. Let's proceed to revert #506.