Skip to content

Ensure that no endpoint throws exceptions but rather returns a proper response #1576

@netomi

Description

@netomi

Various endpoints do handling like that:

        var user = users.findLoggedInUser();
        if (user == null) {
            throw new ResponseStatusException(HttpStatus.FORBIDDEN);
        }

that normally results in the proper http responses as spring handles that automatically.

However, with a configuration like that:

server:
  error:
    path: /server-error
    whitelabel:
      enabled: false

a specific ErrorHandler is activated that redirects all exceptions to the /error frontend page.

This is wrong on multiple levels, as e.g. api calls should not redirect there. Additionally, in the open-vsx.org deployment, there is additional configuratoin to redirect /error to a static html page. Now when an api endpoint throws an error to indicate e.g. the user it not logged in anymore, the response contains html with status code 200 while it is expected to have json, leading to weird errors in the frontend as well.

We need to make sure that all api endpoints return proper responses and not rely on spring magic wrt ResponseStatusExceptions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions