Describe the bug When calling /oauth2/authorization/not-existed-registration, this returns 500. Should it return 404?

To Reproduce Calling the endponit /oauth2/authorization/not-existed-registration` returns 500

Expected behavior Calling the endponit /oauth2/authorization/not-existed-registration` returns 404

Sample source code causing this:

https://github.com/spring-projects/spring-security/blob/5.5.0-RC2/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/web/OAuth2AuthorizationRequestRedirectFilter.java#L225

                 try {
            OAuth2AuthorizationRequest authorizationRequest = this.authorizationRequestResolver.resolve(request);
            if (authorizationRequest != null) {
                this.sendRedirectForAuthorization(request, response, authorizationRequest);
                return;
            }
        }
        catch (Exception ex) {
            this.unsuccessfulRedirectForAuthorization(request, response, ex);
            return;
        }

private void unsuccessfulRedirectForAuthorization(HttpServletRequest request, HttpServletResponse response,
            Exception ex) throws IOException {
        this.logger.error(LogMessage.format("Authorization Request failed: %s", ex, ex));
        response.sendError(HttpStatus.INTERNAL_SERVER_ERROR.value(),
                HttpStatus.INTERNAL_SERVER_ERROR.getReasonPhrase());
    }

Comment From: eleftherias

@HungUnicorn This is expected behavior. See gh-5564 for a detailed explanation.