fix(scan): precise 403/404 access codes + already-running guard on POST /api/scan#85
Merged
Merged
Conversation
…cate running scans scanRepository now distinguishes not-found (404), not-owned (403), and not-tracked (404) via a typed ScanAccessError instead of a generic Error that the route turned into a 500, so callers (web Rescan button, depsight_rescan MCP) can tell a permission problem from a scan crash. It also short-circuits when a RUNNING scan already exists for the repo within SCAN_RUNNING_WINDOW_MS (default 5 min), returning the in-flight scan instead of spawning a duplicate that burns GitHub API quota. Genuine scan failures still return 500. Adds scanner + route unit tests (12) covering each status code, the guard, and a negative control. Refs: agent-tasks 5e9a27bc Co-Authored-By: Claude Opus 4.8 (1M context) <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.
What
Two backend fixes to POST /api/scan + scanRepository.
Why
Surfaced by the reviewer of the depsight_rescan MCP tool. The route turned every access failure into a 500, and scanRepository created a new RUNNING scan on every call with no debounce, so a loop (web Rescan button or depsight_rescan) could spawn many concurrent synchronous scans and burn the user's GitHub API quota.
How
Tests
Notes / follow-up
Refs: agent-tasks 5e9a27bc