Escalate auth only on 401/403/404 during remote URL validation#387
Merged
Escalate auth only on 401/403/404 during remote URL validation#387
Conversation
Rework FileValidator.validate_remote_url to honor the lazy-auth contract: probe unauthenticated first and only escalate to authentication when the last HTTP response is 401, 403, or 404.
Non-auth failures (SSL, DNS, 5xx, timeouts, 416 Range Not Satisfiable) no longer trigger auth prompts.
Change _check_with_head and _check_with_range to return tuple[bool, int | None] so the caller can gate escalation on the HTTP status code.
Route escalation through AuthHeaderCache.resolve_and_cache when a cache is available so parallel validation threads serialize prompts via double-checked locking.
Add GitHub 404 disambiguation: before prompting, probe api.github.com/repos/{owner}/{repo} unauthenticated, and if the repo is confirmed public, treat the original 404 as a genuine missing file and skip the auth prompt.
Classify *.github.io hostnames as non-repository so GitHub Pages URLs never trigger auth prompts.
Split get_auth_headers into resolve_credentials (pure, non-interactive) and prompt_for_credentials (interactive, isatty-guarded) to let non-interactive callers opt into resolution without risking prompts.
Update the prompt wording to "Authentication required for {url}".
Update CLAUDE.md and the environment configuration guide to document the lazy-auth invariant, the SRP split, the repo type classification rules, and the GitHub 404 disambiguation behavior.
Extend unit and e2e tests to cover the new escalation contract and the public-skills no-prompt path.
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||
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.
Rework FileValidator.validate_remote_url to honor the lazy-auth contract: probe unauthenticated first and only escalate to authentication when the last HTTP response is 401, 403, or 404. Non-auth failures (SSL, DNS, 5xx, timeouts, 416 Range Not Satisfiable) no longer trigger auth prompts.
Change _check_with_head and _check_with_range to return tuple[bool, int | None] so the caller can gate escalation on the HTTP status code. Route escalation through AuthHeaderCache.resolve_and_cache when a cache is available so parallel validation threads serialize prompts via double-checked locking.
Add GitHub 404 disambiguation: before prompting, probe api.github.com/repos/{owner}/{repo} unauthenticated, and if the repo is confirmed public, treat the original 404 as a genuine missing file and skip the auth prompt. Classify *.github.io hostnames as non-repository so GitHub Pages URLs never trigger auth prompts.
Split get_auth_headers into resolve_credentials (pure, non-interactive) and prompt_for_credentials (interactive, isatty-guarded) to let non-interactive callers opt into resolution without risking prompts. Update the prompt wording to "Authentication required for {url}".
Update CLAUDE.md and the environment configuration guide to document the lazy-auth invariant, the SRP split, the repo type classification rules, and the GitHub 404 disambiguation behavior. Extend unit and e2e tests to cover the new escalation contract and the public-skills no-prompt path.