Merge pull request #12625 from uberbrady/quiet_down_scim_exceptions

Suppress SCIMExceptions from cluttering up Rollbar
This commit is contained in:
snipe 2023-03-06 15:42:58 -08:00 committed by GitHub
commit fffe5da2e0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 3 deletions

View file

@ -6,6 +6,7 @@ use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use App\Helpers\Helper; use App\Helpers\Helper;
use Illuminate\Validation\ValidationException; use Illuminate\Validation\ValidationException;
use Illuminate\Auth\AuthenticationException; use Illuminate\Auth\AuthenticationException;
use ArieTimmerman\Laravel\SCIMServer\Exceptions\SCIMException;
use Log; use Log;
use Throwable; use Throwable;
use JsonException; use JsonException;
@ -28,6 +29,7 @@ class Handler extends ExceptionHandler
\Intervention\Image\Exception\NotSupportedException::class, \Intervention\Image\Exception\NotSupportedException::class,
\League\OAuth2\Server\Exception\OAuthServerException::class, \League\OAuth2\Server\Exception\OAuthServerException::class,
JsonException::class, JsonException::class,
SCIMException::class, //these generally don't need to be reported
]; ];
/** /**
@ -53,7 +55,7 @@ class Handler extends ExceptionHandler
* *
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
* @param \Exception $e * @param \Exception $e
* @return \Illuminate\Http\Response * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse|\Illuminate\Http\Response
*/ */
public function render($request, Throwable $e) public function render($request, Throwable $e)
{ {
@ -70,6 +72,9 @@ class Handler extends ExceptionHandler
return response()->json(Helper::formatStandardApiResponse('error', null, 'invalid JSON'), 422); return response()->json(Helper::formatStandardApiResponse('error', null, 'invalid JSON'), 422);
} }
if ($e instanceof SCIMException) {
return response()->json(Helper::formatStandardApiResponse('error', null, 'invalid SCIM Request'), 400);
}
// Handle Ajax requests that fail because the model doesn't exist // Handle Ajax requests that fail because the model doesn't exist
if ($request->ajax() || $request->wantsJson()) { if ($request->ajax() || $request->wantsJson()) {
@ -113,7 +118,7 @@ class Handler extends ExceptionHandler
* *
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
* @param \Illuminate\Auth\AuthenticationException $exception * @param \Illuminate\Auth\AuthenticationException $exception
* @return \Illuminate\Http\Response * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse
*/ */
protected function unauthenticated($request, AuthenticationException $exception) protected function unauthenticated($request, AuthenticationException $exception)
{ {

View file

@ -117,6 +117,11 @@ $config = [
\Log::info("IGNORING E_WARNING in production mode: ".$args->getMessage()); \Log::info("IGNORING E_WARNING in production mode: ".$args->getMessage());
return true; // "TRUE - you should ignore it!" return true; // "TRUE - you should ignore it!"
} }
$needle = "ArieTimmerman\\Laravel\\SCIMServer\\Exceptions\\SCIMException";
if (App::environment('production') && is_string($args) && strncmp($args, $needle, strlen($needle) ) === 0 ) {
\Log::info("String: '$args' looks like a SCIM Exception; ignoring error");
return true; //yes, *do* ignore it
}
return false; return false;
}, },
], ],