Repository navigation
Fix shared class-level errors/objects lists in 4 DNS response classes - #2216
Conversation
BuddyNSResponse, DNSPodResponse, LuadnsResponse and NsOneResponse declared errors/objects as class-level mutable attributes and appended to them from parse_body_and_errors(). The lists were shared by every response object in the process, so parsed objects accumulated across requests: a get_zone() reading response.objects[0] could receive data from an earlier response, and errors leaked between requests. Initialize fresh per-instance lists before super().__init__() (the base Response constructor calls success(), which reads errors), and convert the class attributes to bare annotations. Regression tests added to all four driver test suites: with the old code they fail (4 failures, 1 error); with this change all 60 tests in the four suites pass.
micafer
left a comment
There was a problem hiding this comment.
Thanks for the fix.
There is some overlap with PR #2066 in NsOneResponse, but I don't consider that a blocker for this focused fix. We can reconcile the overlapping change when updating #2066 against trunk.
One minor, suggestion: the new test classes are currently placed after the if __name__ == "__main__": block. Moving them above that block would ensure they are also discovered when the test modules are executed directly.
Please also add the entry in the changelog.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## trunk #2216 +/- ##
==========================================
+ Coverage 83.64% 83.65% +0.01%
==========================================
Files 352 352
Lines 82321 82393 +72
Branches 8868 8880 +12
==========================================
+ Hits 68855 68921 +66
- Misses 10593 10594 +1
- Partials 2873 2878 +5
🚀 New features to boost your workflow:
|
…ntry - test classes now precede the 'if __name__ == __main__' guard in all four files so they are discovered when modules run directly - CHANGES.rst: entry under the 4.0.0 DNS section - all 64 tests in the four files pass
|
Done, thanks @micafer:
Re: the NsOne overlap with #2066 — happy to reconcile once that one is updated against trunk. |
|
Reconciliation analysis for the #2066 overlap (@aaron-sierra cc @micafer): The NsOneResponse hunks in #2066 and here are semantically identical — both move So whichever PR merges first, the other rebases with at most a same-content conflict — no behavioral decision is needed. If #2066 lands first, its NsOneResponse hunk can simply be dropped in favor of this one (the regression tests here still apply unchanged). |
Removed duplicate entry for DNS response class fixes.
Description
BuddyNSResponse,DNSPodResponse,LuadnsResponseandNsOneResponsedeclareerrors/objectsas class-level mutable attributes and append to them fromparse_body_and_errors(). The lists are therefore shared by every response object in the process:libcloud/dns/drivers/nsone.pyget_zone()readsresponse.objects[0]and can receive data from an earlier response;success()can report stale failures.Reproduced locally against
trunk:Fix
Initialize fresh per-instance
errors/objectslists beforesuper().__init__()(the baseResponseconstructor callssuccess(), which readserrors), and convert the class attributes to bare annotations. Per-request behavior is otherwise unchanged.Tests
Regression tests added to all four driver test suites (
libcloud/test/dns/test_buddyns.py,test_dnspod.py,test_luadns.py,test_nsone.py):test_objects_do_not_accumulate_across_responsestest_errors_do_not_leak_across_responsesWith the old code the four suites report 4 failures + 1 error; with this change all 60 tests pass.
AI Generation Disclosure
Developed with AI assistance (agent workflow): the bug was found by an AST scan for mutated class-level attributes, reproduced against trunk, fixed, and verified with the A/B test run above.