Repository navigation
Fix shared class-level errors/objects lists in 4 DNS response classes - #2216
Open
Hisernberg wants to merge 2 commits into
Open
Hisernberg wants to merge 2 commits into
Hisernberg wants to merge 2 commits into
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
requested changes
Nov 11, 2026
micafer
left a comment
Contributor
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:
|
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.
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.