Fix auto_setup Sci-Hub probe crash: 'int' object has no attribute 'get'#13
Open
cj20092008-boop wants to merge 1 commit into
Open
Conversation
load_stats() returns per-domain dicts plus a `_last_probe` metadata
entry whose value is an int timestamp. The summary comprehension in
scansci_pdf_auto_setup evaluated s.get("reachable") before the
`_`-prefix guard, so for `_last_probe` it called .get() on an int and
raised "'int' object has no attribute 'get'", surfacing as a spurious
"Sci-Hub probe error" even though the probe itself succeeded.
Reorder the conditions to filter `_`-prefixed metadata keys first and
add an isinstance(s, dict) guard.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Summary
scansci_pdf_auto_setupalways reports a Sci-Hub probe failure even though the probe itself completes successfully:The domain probe runs fine — the crash is in the result-summarization line that counts reachable domains.
Root cause
load_stats()(indomain_db.py) returns per-domain dicts plus a metadata entry_last_probe, whose value is aninttimestamp:In
server.py(scansci_pdf_auto_setup), the summary comprehension evaluatess.get("reachable")before the_-prefix guard:Because Python evaluates the left operand of
andfirst, for the_last_probekeysis anint, sos.get(...)raises'int' object has no attribute 'get'beforenot d.startswith("_")ever runs.Fix
Reorder the conditions so the
_-prefixed metadata keys are filtered out first (short-circuit), and add anisinstance(s, dict)guard for robustness:Verification
With the patch applied, the probe + summary runs cleanly:
scansci_pdf_auto_setupnow reports e.g.Sci-Hub: 4 domains reachableinstead of the error.Environment