← Back to PRs

#16962: fix: make auth error detection contextual to prevent false positives

by StressTestor open 2026-02-15 08:44 View on GitHub →
agents stale size: S
## Summary - Replaces overly broad `\b401\b` and `\b403\b` regex patterns in auth error detection with contextual patterns that only match actual HTTP error contexts (e.g., `status: 401`, `http 403`, `got a 401`) - Prevents false positives on legitimate content like "401k retirement plan" or "403 items in the database" - Adds regression tests covering false positive scenarios and real auth errors Fixes #16237 ## Test plan - [x] New test cases for false positives (401k, addresses, section numbers) - [x] New test cases for real auth/billing errors still detected correctly - [x] Full test suite passes (`pnpm test:fast`, `pnpm check`) <!-- greptile_comment --> <h3>Greptile Summary</h3> Replaces overly broad word-boundary patterns (`\b401\b`, `\b403\b`) with contextual regex patterns that only match HTTP status codes in actual error contexts. The new patterns check for keywords like `status`, `code`, `http`, `error`, `got`, `returned`, or `received` before the status code, preventing false positives on legitimate content like "401k retirement plan" or "403 items in database". The changes include comprehensive regression tests covering both false positive scenarios and real auth error detection. <h3>Confidence Score: 5/5</h3> - This PR is safe to merge with minimal risk - The changes are well-tested with comprehensive regression tests covering both false positives and true positives. The regex patterns are carefully crafted to match only legitimate error contexts. The implementation follows the same pattern already established for the 402 billing error (fixed in commit 4f329f92). - No files require special attention <sub>Last reviewed commit: 0b97447</sub> <!-- greptile_other_comments_section --> <!-- /greptile_comment -->

Most Similar PRs