Skip to content

[Cloudflare] Fix list_record_types advertising URL instead of LOC - #2175

Merged
micafer merged 2 commits into
apache:trunkfrom
uttam12331:fix-cloudflare-loc-record-type
Jul 31, 2026
Merged

[Cloudflare] Fix list_record_types advertising URL instead of LOC#2175
micafer merged 2 commits into
apache:trunkfrom
uttam12331:fix-cloudflare-loc-record-type

Conversation

@uttam12331

Copy link
Copy Markdown
Contributor

Summary

The CloudFlare DNS driver's RECORD_TYPE_MAP has one entry that doesn't match the pattern of the rest:

RECORD_TYPE_MAP = {
    RecordType.A: "A",
    ...
    RecordType.SRV: "SRV",
    RecordType.URL: "LOC",   # <-- key/value mismatch
}

Every other entry is an identity mapping, and the value "LOC" shows that LOC support was intended — the key is a copy-paste slip. RecordType.URL and RecordType.LOC both exist in libcloud/dns/types.py.

Because list_record_types() returns RECORD_TYPE_MAP.keys(), the driver:

  • advertises RecordType.URL, which is not a Cloudflare DNS record type (Cloudflare does URL forwarding via Page/Redirect Rules, not DNS records), and
  • omits RecordType.LOC, which Cloudflare does support.

Reproduce

from libcloud.dns.types import RecordType, Provider
from libcloud.dns.providers import get_driver

drv = get_driver(Provider.CLOUDFLARE)("key", "secret")
types = drv.list_record_types()

RecordType.URL in types   # True  -> should be False
RecordType.LOC in types   # False -> should be True

Fix

Correct the key to RecordType.LOC, making it an identity mapping like the others:

RecordType.LOC: "LOC",

The map value isn't consumed by create_record (which passes the record type through directly), so the only observable effect is list_record_types(), which now correctly reports LOC and no longer reports URL. The entry count is unchanged (9).

Tests

Extended test_list_record_types to assert RecordType.LOC is present and RecordType.URL is absent. It fails on the current code and passes with the fix. Full test_cloudflare.py suite: 29 passed. flake8 clean.

The CloudFlare driver's RECORD_TYPE_MAP had an entry keyed on
RecordType.URL with the value "LOC". Every other entry is an identity
mapping, and the value "LOC" shows LOC support was intended: the key is a
copy-paste slip.

As a result list_record_types() advertised RecordType.URL -- which is not
a Cloudflare DNS record type (URL forwarding is done via Page Rules, not
DNS records) -- and omitted RecordType.LOC, which Cloudflare does support.

Correct the key to RecordType.LOC so the supported LOC type is reported
and the unsupported URL type is not. Extends the existing
test_list_record_types to assert LOC is present and URL is absent.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes the Cloudflare DNS driver’s advertised record types by correcting a RECORD_TYPE_MAP key so list_record_types() reports the supported LOC type and no longer reports the unsupported URL type.

Changes:

  • Update Cloudflare driver RECORD_TYPE_MAP to use RecordType.LOC instead of RecordType.URL.
  • Extend the Cloudflare DNS driver test to assert LOC is present and URL is absent.
  • Add a changelog entry describing the fix.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
libcloud/dns/drivers/cloudflare.py Corrects the record type mapping so list_record_types() advertises LOC instead of URL.
libcloud/test/dns/test_cloudflare.py Adds assertions verifying LOC is included and URL is excluded from list_record_types().
CHANGES.rst Documents the Cloudflare list_record_types fix in the changelog.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@micafer micafer left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@micafer
micafer enabled auto-merge July 31, 2026 10:32
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.39%. Comparing base (87c8cb0) to head (deba4cf).

Additional details and impacted files
@@           Coverage Diff           @@
##            trunk    #2175   +/-   ##
=======================================
  Coverage   83.39%   83.39%           
=======================================
  Files         351      351           
  Lines       81519    81521    +2     
  Branches     8747     8747           
=======================================
+ Hits        67982    67984    +2     
  Misses      10744    10744           
  Partials     2793     2793           
Files with missing lines Coverage Δ
libcloud/dns/drivers/cloudflare.py 91.07% <ø> (ø)
libcloud/test/dns/test_cloudflare.py 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@micafer
micafer merged commit 5ffd5ff into apache:trunk Jul 31, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants