Skip to content
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

NETLIFY: provider type netlify: cannot list zones to use the 'all' feature #2931

Closed
jauderho opened this issue May 3, 2024 · 10 comments · Fixed by #2933
Closed

NETLIFY: provider type netlify: cannot list zones to use the 'all' feature #2931

jauderho opened this issue May 3, 2024 · 10 comments · Fixed by #2933

Comments

@jauderho
Copy link
Contributor

jauderho commented May 3, 2024

Describe the bug
I'm starting to test migrations with more providers and in this case, I want to move from Netlify to Cloudflare/BIND

To Reproduce
Steps to reproduce the behavior:

  1. Enter Netlify creds. creds.json is set as follows:

  "netlify": {
    "TYPE": "NETLIFY",
    "token": "$NETLIFY_API_TOKEN",
    "slug": "$NETLIFY_ACCOUNT_SLUG"
  },

  1. When I run env $(cat .env) ~/go/bin/dnscontrol check-creds netlify, I get provider type netlify: cannot list zones to use the 'all' feature

Expected behavior
I'm expecting to get a list of DNS domains back but instead I get provider type netlify: cannot list zones to use the 'all' feature

The Netlify API seems to show that this is possible: https://open-api.netlify.com/#tag/dnsZone/operation/getDnsZones

If I try with env $(cat .env) ~/go/bin/dnscontrol get-zone --format=js netlify - domain.com, I get ailed GetZone gzr: json: cannot unmarshal object into Go struct field dnsZone.domain of type string

DNS Provider

  • NETLIFY
@cafferata
Copy link
Collaborator

Ping @SphericalKat (the maintainer of this provider).

@SphericalKat
Copy link
Contributor

@jauderho I don't remember exactly why it's disabled, but I'll investigate this. Thanks for the report!

@tlimoncelli
Copy link
Contributor

FYI: To enable this feature, complete the providers.ZoneLister interface (i.e. write the ListZones() function for the provider handle)

HTH

@SphericalKat
Copy link
Contributor

Thanks for the help @tlimoncelli! I've created a PR that should close this: #2933

@jauderho
Copy link
Contributor Author

jauderho commented May 3, 2024

So this did not quite work as it looks like things break if there are multiple domains/sites.

  1. testing on personal account with 1 domain results in
env $(cat .env) ~/go/bin/dnscontrol check-creds netlify
domain.com <<< RESULT

So this works.

  1. testing on an account with multiple domains results in
env $(cat .env) ~/go/bin/dnscontrol check-creds netlify
failed GetZone LZ: json: cannot unmarshal object into Go struct field dnsZone.domain of type string. <<< RESULT

This does not work.

@SphericalKat
Copy link
Contributor

@jauderho Interesting, I've been testing on a project with multiple sites, and it seems to work for me.
image

The API spec for this particular route also mentions that the field domain in the response is indeed a string.
image

I wonder if it'd be possible for you to call this route with your credentials, so I could check what exactly it's returning?

@jauderho
Copy link
Contributor Author

jauderho commented May 4, 2024

@SphericalKat

Looks like "domain" is showing as null but "name" is available. These sites were inherited so I do not have the full context around how things were set up.

For my personal account with a single entry that seems to be working, I get the following:

[
  {
    "id": "661f52225fc4e6c559503a21",
    "name": "domain.org",
    "errors": [],
    "supported_record_types": [
      "A",
      "AAAA",
      "MX",
      "CNAME",
      "TXT",
      "NS",
      "SPF",
      "ALIAS",
      "SRV",
      "NETLIFY",
      "NETLIFYv6",
      "CAA"
    ],
    "user_id": "661f4b7b03f27dcfef1e0651",
    "created_at": "2024-04-17T04:37:55.719Z",
    "updated_at": "2024-04-17T04:37:55.719Z",
    "records": [],
    "dns_servers": [
      "dns1.p09.nsone.net",
      "dns2.p09.nsone.net",
      "dns3.p09.nsone.net",
      "dns4.p09.nsone.net"
    ],
    "account_id": "661f4b7b03f27dcfef1e0652",
    "site_id": null,
    "account_slug": "license-0b",
    "account_name": "license-0b",
    "domain": null,
    "ipv6_enabled": null,
    "dedicated": null
  }
]

For the one with multiples that is not working:

[
  {
    "id": "5f466f08181a609781345f7c",
    "name": "post.app",
    "errors": [],
    "supported_record_types": [
      "A",
      "AAAA",
      "MX",
      "CNAME",
      "TXT",
      "NS",
      "SPF",
      "ALIAS",
      "SRV",
      "NETLIFY",
      "NETLIFYv6",
      "CAA"
    ],
    "user_id": "564f379271e20a02bd0000a4",
    "created_at": "2020-08-26T14:17:44.836Z",
    "updated_at": "2022-12-22T23:16:12.437Z",
    "records": [],
    "dns_servers": [
      "dns1.p03.nsone.net",
      "dns2.p03.nsone.net",
      "dns3.p03.nsone.net",
      "dns4.p03.nsone.net"
    ],
    "account_id": "59921be60752d01b202d2b9a",
    "site_id": null,
    "account_slug": "pos",
    "account_name": "Pos",
    "domain": null,
    "ipv6_enabled": null,
    "dedicated": null
  },
  {
    "id": "5e68fad7b493782d64227add",
    "name": "vy.com",
    "errors": [],
    "supported_record_types": [
      "A",
      "AAAA",
      "MX",
      "CNAME",
      "TXT",
      "NS",
      "SPF",
      "ALIAS",
      "SRV",
      "NETLIFY",
      "NETLIFYv6",
      "CAA"
    ],
    "user_id": "5bbf641667610c77a16d4adb",
    "created_at": "2020-03-11T14:51:03.532Z",
    "updated_at": "2022-12-22T23:12:33.279Z",
    "records": [],
    "dns_servers": [
      "dns1.p07.nsone.net",
      "dns2.p07.nsone.net",
      "dns3.p07.nsone.net",
      "dns4.p07.nsone.net"
    ],
    "account_id": "59921be60752d01b202d2b9a",
    "site_id": "d0413da6-3d68-4951-835f-e64218f458af",
    "account_slug": "pos",
    "account_name": "Pos",
    "domain": null,
    "ipv6_enabled": null,
    "dedicated": null
  },
  {
    "id": "5e0f74e55fb2865c9b18f4d3",
    "name": "nth.com",
    "errors": [],
    "supported_record_types": [
      "A",
      "AAAA",
      "MX",
      "CNAME",
      "TXT",
      "NS",
      "SPF",
      "ALIAS",
      "SRV",
      "NETLIFY",
      "NETLIFYv6",
      "CAA"
    ],
    "user_id": "564f761371e20a5a24000008",
    "created_at": "2020-01-03T17:07:50.154Z",
    "updated_at": "2022-12-22T23:11:45.430Z",
    "records": [],
    "dns_servers": [
      "dns1.p07.nsone.net",
      "dns2.p07.nsone.net",
      "dns3.p07.nsone.net",
      "dns4.p07.nsone.net"
    ],
    "account_id": "59921be60752d01b202d2b9a",
    "site_id": "305310d5-b7d1-4c9d-bae3-4050742c4519",
    "account_slug": "pos,
    "account_name": "Pos",
    "domain": null,
    "ipv6_enabled": null,
    "dedicated": null
  },
  {
    "id": "5dd2cb40ac46da94e5605181",
    "name": "xxp.chat",
    "errors": [],
    "supported_record_types": [
      "A",
      "AAAA",
      "MX",
      "CNAME",
      "TXT",
      "NS",
      "SPF",
      "ALIAS",
      "SRV",
      "NETLIFY",
      "NETLIFYv6",
      "CAA"
    ],
    "user_id": "564f761371e20a5a24000008",
    "created_at": "2019-11-18T16:48:00.667Z",
    "updated_at": "2022-12-22T23:11:19.405Z",
    "records": [],
    "dns_servers": [
      "dns1.p07.nsone.net",
      "dns2.p07.nsone.net",
      "dns3.p07.nsone.net",
      "dns4.p07.nsone.net"
    ],
    "account_id": "59921be60752d01b202d2b9a",
    "site_id": "4b80bb8f-3b56-4917-b769-4be87705c5fa",
    "account_slug": "pos",
    "account_name": "Pos",
    "domain": null,
    "ipv6_enabled": null,
    "dedicated": null
  },
  {
    "id": "5cdae80b1ef5fc018152ca9b",
    "name": "tki.com",
    "errors": [],
    "supported_record_types": [
      "A",
      "AAAA",
      "MX",
      "CNAME",
      "TXT",
      "NS",
      "SPF",
      "ALIAS",
      "SRV",
      "NETLIFY",
      "NETLIFYv6",
      "CAA"
    ],
    "user_id": "564f761371e20a5a24000008",
    "created_at": "2019-05-14T16:08:43.134Z",
    "updated_at": "2022-12-22T23:09:18.789Z",
    "records": [],
    "dns_servers": [
      "dns1.p07.nsone.net",
      "dns2.p07.nsone.net",
      "dns3.p07.nsone.net",
      "dns4.p07.nsone.net"
    ],
    "account_id": "59921be60752d01b202d2b9a",
    "site_id": "6b7a5de4-59fd-4919-b719-d38c18ae5fbe",
    "account_slug": "pos",
    "account_name": "Pos",
    "domain": null,
    "ipv6_enabled": null,
    "dedicated": null
  },
  {
    "id": "5ccb56a20b1658efdd2fa865",
    "name": "da.com",
    "errors": [],
    "supported_record_types": [
      "A",
      "AAAA",
      "MX",
      "CNAME",
      "TXT",
      "NS",
      "SPF",
      "ALIAS",
      "SRV",
      "NETLIFY",
      "NETLIFYv6",
      "CAA"
    ],
    "user_id": "564f761371e20a5a24000008",
    "created_at": "2019-05-02T20:44:18.703Z",
    "updated_at": "2022-12-22T23:09:12.628Z",
    "records": [],
    "dns_servers": [
      "dns1.p03.nsone.net",
      "dns2.p03.nsone.net",
      "dns3.p03.nsone.net",
      "dns4.p03.nsone.net"
    ],
    "account_id": "59921be60752d01b202d2b9a",
    "site_id": "f8a7881c-94c6-4ec1-a575-a13ec58520ed",
    "account_slug": "pos",
    "account_name": "Pos",
    "domain": null,
    "ipv6_enabled": null,
    "dedicated": null
  },
  {
    "id": "5c65c799d91c8114d9864cbd",
    "name": "fy.com",
    "errors": [],
    "supported_record_types": [
      "A",
      "AAAA",
      "MX",
      "CNAME",
      "TXT",
      "NS",
      "SPF",
      "ALIAS",
      "SRV",
      "NETLIFY",
      "NETLIFYv6",
      "CAA"
    ],
    "user_id": "580535fe71e20a269856fc5b",
    "created_at": "2019-02-14T19:55:05.156Z",
    "updated_at": "2022-12-22T23:08:22.532Z",
    "records": [],
    "dns_servers": [
      "dns1.p01.nsone.net",
      "dns2.p01.nsone.net",
      "dns3.p01.nsone.net",
      "dns4.p01.nsone.net"
    ],
    "account_id": "59921be60752d01b202d2b9a",
    "site_id": null,
    "account_slug": "pos",
    "account_name": "Pos",
    "domain": {
      "id": "5c65c799d91c8114d9864cbe",
      "name": "fyreipsum.com",
      "user_id": "580535fe71e20a269856fc5b",
      "created_at": "2019-02-14T19:55:12.446Z",
      "updated_at": "2024-01-16T03:00:18.894Z",
      "expires_at": "2025-02-14T19:55:06.000Z",
      "registered_at": "2019-02-14T19:55:06.000Z",
      "renewal_price": "18.99",
      "auto_renew": true,
      "auth_code": null,
      "transferred_at": null,
      "auto_renew_at": "2025-01-13T19:55:06.000Z"
    },
    "ipv6_enabled": null,
    "dedicated": false
  },
  {
    "id": "599430080752d02e85f7de14",
    "name": "a.website",
    "errors": [],
    "supported_record_types": [
      "A",
      "AAAA",
      "MX",
      "CNAME",
      "TXT",
      "NS",
      "SPF",
      "ALIAS",
      "SRV",
      "NETLIFY",
      "NETLIFYv6",
      "CAA"
    ],
    "user_id": "5756f2bd4e9f9d740da3d879",
    "created_at": "2017-08-16T11:44:08.751Z",
    "updated_at": "2022-12-22T23:05:53.162Z",
    "records": [],
    "dns_servers": [
      "dns1.p06.nsone.net",
      "dns2.p06.nsone.net",
      "dns3.p06.nsone.net",
      "dns4.p06.nsone.net"
    ],
    "account_id": "59921be60752d01b202d2b9a",
    "site_id": "c8129825-8425-45eb-9525-698137d1abed",
    "account_slug": "pos",
    "account_name": "Pos",
    "domain": null,
    "ipv6_enabled": null,
    "dedicated": null
  }
]

@SphericalKat
Copy link
Contributor

SphericalKat commented May 4, 2024

Thanks for the response @jauderho
There seems to be an open issue on Netlify's end about the discrepancy in their API responses: netlify/open-api#511

I'm not sure what the ideal way to handle this scenario is, since sometimes the domain field does indeed contain a string, and sometimes it contains the object; the API's internal implementation is opaque to us :/

Do you have any suggestions as to how you'd like such a case handled? I was thinking, attempt to unmarshal to one type, and upon failure, try the other.

@tlimoncelli
Copy link
Contributor

FYI: I'm good with unmarshalling twice. You can get fancy and use json.RawMessage so that you're only doing a specific field twice, but I think that's going to be a lot of extra work for not much benefit. Either way, make sure to include comments so the next person looking at the code understands what's going on.

@jauderho
Copy link
Contributor Author

@SphericalKat Sorry for the delay in response but I think the best fix is for Netlify to have predictable output from their API.

I think your idea of unmarshal, test, unmarshal is probably the next best alternative. Else, it looks like you may want to select for the "name" field instead of the "domain" field until this gets fixed upstream.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants