Conversation
…update_record - Fixed cloudflare.py: Changed priority order for proxied, tags, and settings - Added comprehensive tests for all providers to verify extra parameter priority - Tests added/updated: cloudflare, huaweidns, alidns, dnspod, dnscom, aliesa, namesilo, tencentcloud - All 218 provider tests passing Co-authored-by: NewFuture <[email protected]>
|
@copilot fix py2.7 |
- Changed from `from unittest.mock import patch` to `from base_test import patch` - This ensures compatibility with Python 2.7 where mock is a separate package - All 218 provider tests still passing Co-authored-by: NewFuture <[email protected]>
Fixed in commit 2e4d4f2. Changed the import from |
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a priority issue in the CloudFlare provider where old_record values were incorrectly taking precedence over user-provided extra parameters in _update_record(). The fix ensures that extra parameters always override old_record values, respecting user intent. Additionally, comprehensive unit tests were added across all BaseProvider implementations to verify correct priority behavior and prevent future regressions.
Key Changes:
- Reversed priority order in CloudFlare provider for
proxied,tags, andsettingsfields to prioritizeextraoverold_record - Added 8 new/updated unit tests across all providers to validate
extraparameter priority - All 218 tests passing with no behavioral changes to other providers
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| ddns/provider/cloudflare.py | Fixed priority order to ensure extra parameters take precedence over old_record values for proxied, tags, and settings fields |
| tests/test_provider_cloudflare.py | Updated existing test to verify correct priority behavior with additional test cases for tags and settings |
| tests/test_provider_huaweidns.py | Added new test test_update_record_extra_priority_over_old_record to verify priority behavior |
| tests/test_provider_alidns.py | Added new test test_update_record_extra_priority_over_old_record to verify priority behavior |
| tests/test_provider_dnspod.py | Added new test test_update_record_extra_priority_over_old_record to verify priority behavior |
| tests/test_provider_dnscom.py | Added new test test_update_record_extra_priority_over_old_record to verify priority behavior |
| tests/test_provider_aliesa.py | Added new test test_update_record_extra_priority_over_old_record to verify priority behavior |
| tests/test_provider_namesilo.py | Added new test test_update_record_extra_priority_over_old_record to verify priority behavior |
| tests/test_provider_tencentcloud.py | Added new test test_update_record_extra_priority_over_old_record to verify priority behavior |
|
@copilot Using eval() to parse JSON is unsafe and should be replaced with json.loads(). While this is test code, it sets a bad example and could pose security risks if similar patterns are copied to production code. |
- Replaced eval(call_kwargs["body"]) with json.loads(call_kwargs["body"]) - Using eval() to parse JSON is a security risk and bad practice - json.loads() is the safe and proper way to parse JSON strings - All tests still passing Co-authored-by: NewFuture <[email protected]>
Fixed in commit 4c8a7e3. Replaced |
|
@copilot fix lint |
… test - Fixed W293 linting error on line 236 - Removed trailing whitespace from blank line after import statement - All tests still passing Co-authored-by: NewFuture <[email protected]>
... Fixed in commit 8f2b9a1. Removed trailing whitespace from the blank line. |
Issue
When calling
_update_record()across providers, theextraparameter should take priority over values fromold_record. However, CloudFlare provider had the priority order reversed for certain fields.Problem
In
ddns/provider/cloudflare.py, the_update_recordmethod was incorrectly prioritizingold_recordvalues overextraparameters:This meant that even if a user explicitly passed
proxied=Truein theextraparameter, if the old record hadproxied=False, the old value would be used instead of the user's intended value.Solution
Corrected the priority order to ensure
extraparameters always take precedence:Now if the user provides a value in
extra, it will be used. Only whenextradoesn't contain the key will the old_record value be used as a fallback.Testing
Added comprehensive unit tests for all BaseProvider implementations to verify correct priority behavior:
test_update_record_extra_priority_over_old_recordtest_update_record_extra_priority_over_old_recordtest_update_record_extra_priority_over_old_recordtest_update_record_extra_priority_over_old_recordtest_update_record_extra_priority_over_old_recordtest_update_record_extra_priority_over_old_recordtest_update_record_extra_priority_over_old_recordAll other providers were verified to already have correct priority implementation.
Test Results
Impact
Only CloudFlare provider behavior changes. When users specify
proxied,tags, orsettingsthrough theextraparameter, these values will now correctly override the corresponding values fromold_record, ensuring user intent is respected.Fixes #565
Original prompt
Fixes #565
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.