Skip to content

Fix result counter accumulating across usernames due to module-level global - #3040

Open
vtino17 wants to merge 2 commits into
sherlock-project:masterfrom
vtino17:fix/result-counter
Open

vtino17 wants to merge 2 commits into
sherlock-project:masterfrom
vtino17:fix/result-counter

Conversation

@vtino17

@vtino17 vtino17 commented Jul 21, 2026 •

Copy link
Copy Markdown

Fixes #2990

Problem

The result counter is a module-level global, so counts accumulate across usernames. finish() also increments the counter and subtracts one, making the behavior dependent on call order.

Change

  • scope the counter to each QueryNotifyPrint instance
  • increment it only when a claimed result is reported
  • have finish() read the current count without mutating it

Regression test

The test creates two notifier instances and verifies independent totals of two and one; it also proves finish() does not increment either counter.

Local result: 1 passed.

vtino17 and others added 2 commits August 11, 2026 06:21
The result counter used a module-level global variable (globvar) that
was never reset between username scans. When scanning multiple usernames,
the count for each subsequent user included results from all previous ones.

Fix: move counter to instance attribute (_result_count) initialized
in QueryNotifyPrint.__init__, replacing the fragile module-level global.

Fixes sherlock-project#2990
@vtino17
vtino17 force-pushed the fix/result-counter branch from c5d2b9a to e433aa4 Compare August 10, 2026 23:36
@vtino17
vtino17 requested a review from ppfeister as a code owner August 10, 2026 23:36
@vtino17

vtino17 commented Aug 10, 2026

Copy link
Copy Markdown
Author

I cleaned this branch so it no longer contains the unrelated output-flag change or the accidental pr-body.md file, rebased it onto current master, and added a regression test proving counts are isolated between notifier instances and finish does not increment them. Local result: 1 passed.

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.

fix: result counter accumulates across usernames due to module-level global

1 participant