Confirm this is a Go library issue and not an underlying Cloudflare API issue
Describe the bug
I have an existing CNAME record sample.apps.io that points to aaaaa.elb.us-east-1.amazonaws.com and Im trying to update the contents to point to a new load balancer when --name is fully qualified for flarectl dns create-or-update.
To Reproduce
The following attempt fails with:
$ flarectl dns create-or-update --proxy --zone apps.io --name sample.apps.io --content bbbbb.elb.us-east-1.amazonaws.com --type CNAME
Error creating DNS record: An A, AAAA, or CNAME record with that host already exists. For more details, refer to <https://developers.cloudflare.com/dns/manage-dns-records/troubleshooting/records-with-same-name/>. (81053)
flarectl is trying to create the record instead of update it if you look at the error meessage.
It seems that because the flag --name sample.apps.io is fully qualified instead of short --name sample this gets concatentated preemptively:
|
records, _, err := api.ListDNSRecords(context.Background(), cloudflare.ZoneIdentifier(zoneID), cloudflare.ListDNSRecordsParams{Name: name + "." + zone}) |
This causes there to be no matching records (
sample.apps.io.apps.io) to update and causes the create to fail instead since its still using what was passed in by
--name:
Ive noticed some inconsistency with --name for the CLI dns subcommands. flarectl dns list has differing results for FQDN vs short:
flarectl dns list FQDN:
$ flarectl dns list --zone apps.io --type CNAME --name sample.apps.io
ID | TYPE | NAME | CONTENT | PROXIED | TTL
-----------------------------------+-------+------------------------------+-------------------------------------------------------------------------------+---------+------
id123456 | CNAME | sample.apps.io | aaaaa.elb.us-east-1.amazonaws.com | true | 1
flarectl dns list short:
$ flarectl dns list --zone apps.io --type CNAME --name sample
ID | TYPE | NAME | CONTENT | PROXIED | TTL
-----+------+------+---------+---------+------
create and update dns subcommands will handle both FQDN and short. Heres the result of update:
$ flarectl dns update --id id123456 --proxy --zone apps.io --name sample.apps.io --content bbbbb.elb.us-east-1.amazonaws.com --type CNAME
$cloudinfra flarectl dns update --id id123456 --proxy --zone apps.io --name sample --content cccccc.elb.us-east-1.amazonaws.com --type CNAME
Nothing is returned but records update as expected
Suggestion
flarectl should have consistent behavior across the various dns subcommands consumption of --name. It seems like supporting both FQDN and short for --name for create-or-update and list would ensure it doesnt break existing behavior.
OS
macOS
Go version
Go 1.22.0
Library version
github.com/cloudflare/cloudflare-go/v0.115.0
Confirm this is a Go library issue and not an underlying Cloudflare API issue
Describe the bug
I have an existing CNAME record
sample.apps.iothat points toaaaaa.elb.us-east-1.amazonaws.comand Im trying to update the contents to point to a new load balancer when--nameis fully qualified forflarectl dns create-or-update.To Reproduce
The following attempt fails with:
It seems that because the flag
--name sample.apps.iois fully qualified instead of short--name samplethis gets concatentated preemptively:cloudflare-go/cmd/flarectl/dns.go
Line 86 in 57714bf
sample.apps.io.apps.io) to update and causes the create to fail instead since its still using what was passed in by--name:cloudflare-go/cmd/flarectl/dns.go
Line 117 in 57714bf
Ive noticed some inconsistency with
--namefor the CLIdnssubcommands.flarectl dns listhas differing results for FQDN vs short:flarectl dns listFQDN:flarectl dns listshort:createandupdatedns subcommands will handle both FQDN and short. Heres the result of update:Suggestion
flarectl should have consistent behavior across the various
dnssubcommands consumption of--name. It seems like supporting both FQDN and short for--nameforcreate-or-updateandlistwould ensure it doesnt break existing behavior.OS
macOS
Go version
Go 1.22.0
Library version
github.com/cloudflare/cloudflare-go/v0.115.0