Download: do not modify the caller's options record - #102
Open
fingolfin wants to merge 1 commit into
Open
Conversation
Filling in the defaults for 'verifyCert' and 'maxTime' wrote into the record the caller passed in, so a record reused across several calls kept the settings from the first one. Only visible when the preferences differ from their defaults -- with the shipped values neither branch is taken -- which is why the test sets DownloadMaxTime first. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #102 +/- ##
==========================================
+ Coverage 86.24% 86.30% +0.05%
==========================================
Files 32 32
Lines 1905 1906 +1
==========================================
+ Hits 1643 1645 +2
+ Misses 262 261 -1
🚀 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.
Filling in the defaults for
verifyCertandmaxTimewrites into the recordthe caller passed in, so a record reused across several calls keeps the
settings from the first one.
What makes this worth fixing rather than documenting is when it happens.
With the shipped preferences it does not happen at all --
DownloadMaxTimeis0, which is not anIsPosInt, andDownloadVerifyCertificateistrue, soneither branch is taken:
So it is invisible to anyone testing a stock configuration, and shows up only
for users who have changed a preference. It bites soonest in a retry loop,
since the natural way to write one hoists the option record out of the loop.
The fix is one
ShallowCopy, which is enough because only top-levelcomponents are assigned. The
via DownloadURLmethod already copies therecord before touching it, which suggests the behaviour was not intended.
The test sets
DownloadMaxTimefirst, for the reason above; without the fixit reports
[ "maxTime" ]instead of[ ].gap --packagedirs $PWD tst/testall.g: 0 failures in 22 files.Found while writing https://github.com/gap-packages/ArtifactManager, which
currently passes a fresh record on every call to work around this.
CC @ThomasBreuer