fix: downgrade apache-libcloud to 3.2.0 to fix Cloudflare DNS registration#618
Merged
dahagag merged 6 commits intoJun 1, 2026
Merged
Conversation
…ation apache-libcloud 3.6.0 introduced incomplete error handling in the Cloudflare DNS driver. Version 3.6.0 added new error codes (81057, 81058) with special handling, but when Cloudflare returns errors during record CREATION (not update), there's no record_id in the context, causing exception constructors to fail with: TypeError: __init__() missing 1 required positional argument: 'record_id' Version 3.2.0 was the last known working version (used in production before June 2022 requirements upgrade). It has simpler error handling where unknown error codes fall back to LibcloudError without requiring special parameters. Fixes client registration MX record creation failures.
Both client and server dependencies must use the same libcloud version to avoid pip resolution conflicts when installing as opwen_email_client[opwen_email_server].
apache-libcloud 3.2.0 doesn't support Python 3.12 because it tries to import match_hostname from ssl module, which was removed in Python 3.12. Python 3.12 support was added in libcloud 3.8.0 (beta) and 3.9.0 (stable). Upgrading to latest 3.9.1 which should also fix the Cloudflare DNS parse_error bug that was introduced in 3.6.0.
apache-libcloud 3.9.0+ requires Python 3.10+, but the server uses Python 3.9. Version 3.8.0 is the last version that supports Python 3.9 while also adding Python 3.12 (beta) support.
Changes: 1. Import RecordAlreadyExistsError for type-safe exception handling 2. When MX record already exists, verify it points to correct mail server 3. Automatically update record if it points to wrong server 4. Add comprehensive tests for both scenarios: - Record exists with correct value (no update needed) - Record exists with wrong value (updates to correct server) Benefits: - Prevents silent failures where MX record points to wrong server - More robust DNS management during client registration - Type-safe exception handling (no string matching) - Better logging with before/after values on updates
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Client registration was failing with
TypeError: __init__() missing 1 required positional argument: 'record_id'during DNS MX record creation. The error occurred inapache-libcloud 3.6.0's Cloudflare DNS driver when handling errors during record creation.Root Cause
record_idin contextrecord_idparameterssl.match_hostnameremoved)Python Version Constraints
Solution
1. Upgrade to apache-libcloud 3.8.0
2. Refactor DNS Error Handling
RecordAlreadyExistsErrorinstead of string matching on genericLibcloudErrormx.sendgrid.net)Changes
requirements.txt:apache-libcloud==3.6.0→apache-libcloud==3.8.0requirements-webapp.txt:apache-libcloud==3.6.0→apache-libcloud==3.8.0opwen_email_server/services/dns.py:RecordAlreadyExistsErrorfor type-safe exception handlingtests/opwen_email_server/services/test_dns.py:RecordAlreadyExistsErrorBenefits
Testing
test-local(Python 3.12) andtest-server(Python 3.9)