Skip to content

fix: stop reporting client-error OAuth exceptions to Nightwatch - #261

Merged
paulocastellano merged 2 commits into
mainfrom
fix/ignore-oauth-client-error-reporting
Aug 9, 2026
Merged

fix: stop reporting client-error OAuth exceptions to Nightwatch#261
paulocastellano merged 2 commits into
mainfrom
fix/ignore-oauth-client-error-reporting

Conversation

@paulocastellano

Copy link
Copy Markdown
Contributor

Summary

  • Passport's TokenGuard explicitly calls report() on every failed bearer-token check (League\OAuth2\Server\Exception\OAuthServerException), including plain 401s from invalid/expired/missing tokens. This was flooding Nightwatch with alerts for bot/scanner traffic hitting the public MCP endpoint, and applies equally to the public REST API.
  • Added dontReportWhen in bootstrap/app.php to ignore OAuthServerException with getHttpStatusCode() < 500 — i.e. client errors (401/400/etc.), consistent with how Laravel already treats AuthenticationException/AuthorizationException/ValidationException by default. Genuine server_error (500) responses are still reported.

Test plan

  • tests/Feature/Passport/OAuthServerExceptionReportingTest.php — asserts client-error variants (accessDenied, invalidGrant, invalidRequest) are not reported, serverError (500) is still reported, and unrelated exceptions are unaffected.
  • vendor/bin/pint --dirty --format agent
  • php artisan test --compact --filter=Passport and tests/Feature/Mcp (179 tests passing)

League\OAuth2\Server\Exception\OAuthServerException with a status
below 500 (invalid/missing/expired bearer tokens, invalid_grant, etc.)
represents a client error, not an application failure, but Passport's
TokenGuard explicitly calls report() on every failed bearer-token
check. This was flooding Nightwatch with 401 noise from bots probing
the public MCP endpoint. Actual server_error (500) responses are still
reported.
@paulocastellano
paulocastellano merged commit 4be33d0 into main Aug 9, 2026
5 checks passed
@paulocastellano
paulocastellano deleted the fix/ignore-oauth-client-error-reporting branch August 9, 2026 15:01
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.

1 participant