Skip to content

Conversation

@amiller
Copy link
Collaborator

@amiller amiller commented Dec 31, 2025

encountered by @jameslbarnes

Two bugs that caused all existing DNS records to be deleted:

  1. XML namespace mismatch: XPath queries used https:// but Namecheap API returns http:// namespace, causing get_dns_records() to always return 0 records.

  2. DNSRecord to dict conversion: create_dns_record() and delete_dns_record() passed DNSRecord objects to _set_dns_records() which expected dicts.

🤖 Generated with Claude Code

Namecheap DNS Provider Bug Fixes

Fixes two bugs that cause all existing DNS records to be deleted when adding new records.

Bug 1: XML Namespace Mismatch (Critical)

The XPath queries used https:// in the namespace, but Namecheap's API returns http://:

# Before (broken)
root.find('.//{https://api.namecheap.com/xml.response}Errors')

# After (fixed)
root.find('.//{http://api.namecheap.com/xml.response}Errors')

This caused get_dns_records() to always return 0 records.

Reference: Namecheap API Intro documents the namespace as
http://api.namecheap.com/xml.response.

Bug 2: DNSRecord to Dict Conversion

create_dns_record() and delete_dns_record() passed DNSRecord dataclass objects to _set_dns_records(), which expects List[Dict] and calls
.get() on each item.

This bug was masked by Bug 1 (no existing records returned = no type mismatch triggered).

Root Cause

Namecheap's API uses a read-modify-write pattern—setHosts replaces all records. Because Bug 1 made getHosts return 0 records, every
setHosts call sent only the new record, deleting everything else.

Testing

After fix, existing records are preserved when adding new ones.

Two bugs that caused all existing DNS records to be deleted:

1. XML namespace mismatch: XPath queries used https:// but Namecheap
   API returns http:// namespace, causing get_dns_records() to always
   return 0 records.

2. DNSRecord to dict conversion: create_dns_record() and delete_dns_record()
   passed DNSRecord objects to _set_dns_records() which expected dicts.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@amiller amiller requested a review from Leechael December 31, 2025 18:27
Copy link
Contributor

@Leechael Leechael left a comment

Choose a reason for hiding this comment

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

lgtm

@Leechael Leechael merged commit 386a2e9 into Dstack-TEE:main Jan 1, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants