Fix: Pagination bug, atomic JSONL export, resilient JSON parsing - #4
Merged
Merged
Conversation
- Fix pagination in fetch_all_commits: params were dropped after page 1, causing per_page to fall back to 30 instead of 100 (3x more API calls) - Atomic JSONL export: write to .tmp then os.replace() to prevent data loss if process crashes mid-export - Add try/except on all json.loads() in JSONL readers (db.py, deep_scan.py, silent_scan.py, render.py) so one malformed line doesn't crash the pipeline - Fix undefined suspects_count and unused raw_combined in deep_scan.py - Ruff cleanup across 11 files
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
Three real bugs that can cause data loss or unnecessary API usage.
1. Pagination params dropped after page 1 (
deep_scan.py)fetch_all_commits()passesparams(includingper_page=100) only on the first request. Subsequent pages useparams=None, so GitHub defaults toper_page=30. This means 3x more API calls than necessary on every deep scan, burning through rate limits faster.2. JSONL export not atomic (
db.py)export_to_jsonl()opens the file in"w"mode (truncates immediately) then writes patterns and advisories. If the process crashes mid-write (SIGTERM from GitHub Actions timeout, OOM, etc.), the JSONL file is truncated and unrecoverable. Fixed by writing to a.tmpfile first then usingos.replace()for an atomic swap.3. Missing JSON error handling in JSONL readers
Every JSONL reader (
db.py,deep_scan.py,silent_scan.py,render.py) callsjson.loads()without try/except. A single malformed line crashes the entire pipeline. Now skips bad lines with a warning instead of crashing.Also includes the
suspects_countcrash fix and ruff cleanup (same as PR #1, included for branch independence).Test plan
python -m src.deep_scan owner/repo --since 2025-01-01 --max 10- verify pagination uses 100 per pagedata/silent_results.jsonl- verify render doesn't crashruff check src/passes with 0 errors