Skip to content

fix: replace module-level counter with instance variable in QueryNotifyPrint#2995

Open
Aryan-Shastri wants to merge 2 commits into
sherlock-project:masterfrom
Aryan-Shastri:fix/result-counter-global-state
Open

fix: replace module-level counter with instance variable in QueryNotifyPrint#2995
Aryan-Shastri wants to merge 2 commits into
sherlock-project:masterfrom
Aryan-Shastri:fix/result-counter-global-state

Conversation

@Aryan-Shastri

@Aryan-Shastri Aryan-Shastri commented Jun 10, 2026

Copy link
Copy Markdown

Problem

globvar in notify.py is module-level and never resets between username scans.
Running sherlock user1 user2 gives user2 an inflated count — it starts counting
from where user1 left off.

Additionally, finish() called countResults() an extra time then subtracted 1
to compensate, which is fragile and obscures the real bug.

Fix

  • Remove module-level globvar
  • Add self._result_count = 0 to QueryNotifyPrint.__init__
  • countResults() now increments self._result_count
  • finish() reads self._result_count directly — no extra increment, no off-by-one

Behaviour

Each QueryNotifyPrint instance tracks its own count, so multiple username scans
in one process each report correct independent totals.

Test

notifier1 = QueryNotifyPrint()  # scan user1 → 3 results → reports 3
notifier2 = QueryNotifyPrint()  # scan user2 → 5 results → reports 5 (not 8)


Fixes #2990

When the remote MANIFEST_URL returns a non-200 response (e.g. 404 on
older installations pointing to a stale URL), try loading the bundled
sherlock_project/resources/data.json instead of crashing. Prints a
warning so users know the remote fetch failed. If the local fallback
also doesn't exist, raises a FileNotFoundError with an actionable
message suggesting `pip install -U sherlock-project`.

Fixes sherlock-project#2924
…fyPrint

`globvar` was a module-level integer that accumulated across all username
scans in a single process. When running `sherlock user1 user2`, user2's
result count started from where user1's left off, producing inflated totals.

Additionally, `finish()` called `countResults()` one extra time then
subtracted 1 to compensate — a fragile workaround that masked the issue.

Replace `globvar` with `self._result_count = 0` initialised in `__init__`,
so each `QueryNotifyPrint` instance maintains its own independent counter.
`finish()` now reads `self._result_count` directly.

Fixes sherlock-project#2990
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant