Skip to content

[Bug]: Dashboard API exception handler returns HTTP 200 for error responses #4437

Closed

Description

@sivakumar-mahalingam

What happened?

The dashboard REST API exception handler includes the intended HTTP status in the JSON response body but does not set the actual HTTP response status.

For example, an unauthenticated dashboard API request returns a body similar to:

{
  "code": 403,
  "message": "Please login first",
  "requestId": ""
}

Affects Versions

0.9.0-incubating / 0.9.x

What table formats are you seeing the problem on?

No response

What engines are you seeing the problem on?

AMS

How to reproduce

  1. Start AMS locally.

  2. Send a dashboard API request with X-Request-Source: Web without an authenticated session:

curl --include \
  --header "X-Request-Source: Web" \
  http://localhost:1630/api/ams/v1/catalogs
  1. Check the HTTP status line and JSON response body.

The response status is:

HTTP/1.1 200 OK

However, the response body reports a forbidden error:

{
  "code": 403,
  "message": "Please login first",
  "requestId": ""
}

The HTTP status should instead be:

HTTP/1.1 403 Forbidden

The issue can also be reproduced through the existing TestDashboardAuthentication integration test by adding an HTTP status assertion to assertForbidden():

private static void assertForbidden(
    HttpResponse<String> response, String expectedMessage) throws IOException {
  Assertions.assertEquals(403, response.statusCode());

  JsonNode responseBody = OBJECT_MAPPER.readTree(response.body());
  Assertions.assertEquals(403, responseBody.get("code").asInt());
  Assertions.assertEquals(expectedMessage, responseBody.get("message").asText());
}

The new response.statusCode() assertion fails with the current implementation.

Relevant log output

No specific log output is required. The problem is visible in the HTTP response status and JSON body.

Anything else

The issue is in DashboardServer.handleException().

The handler creates an ErrorResponse containing the correct error code, but ctx.json(...) does not set the HTTP response status.

Current implementation:

ctx.json(new ErrorResponse(HttpCode.FORBIDDEN, e.getMessage(), ""));

Suggested implementation:

ctx.status(HttpCode.FORBIDDEN)
    .json(new ErrorResponse(HttpCode.FORBIDDEN, e.getMessage(), ""));

The same change should be made for the other error branches:

public void handleException(Exception e, Context ctx) {
  if (e instanceof ForbiddenException) {
    if (!ctx.req.getRequestURI().startsWith("/api/ams")) {
      ctx.html(getIndexFileContent());
    } else {
      ctx.status(HttpCode.FORBIDDEN)
          .json(new ErrorResponse(HttpCode.FORBIDDEN, e.getMessage(), ""));
    }
  } else if (e instanceof SignatureCheckException) {
    ctx.status(HttpCode.FORBIDDEN)
        .json(new ErrorResponse(HttpCode.FORBIDDEN, "Signature check failed", ""));
  } else {
    ctx.status(HttpCode.INTERNAL_SERVER_ERROR)
        .json(new ErrorResponse(HttpCode.INTERNAL_SERVER_ERROR, e.getMessage(), ""));
  }

  LOG.error("An error occurred while processing the url:{}", ctx.url(), e);
}

The existing authentication integration tests already verify the error code in the JSON body. They should also verify the actual HTTP response status.

Are you willing to submit a PR?

  • Yes I am willing to submit a PR!

Code of Conduct

  • I agree to follow this project's Code of Conduct

Activity

  1. added
    type:bug
    on Oct 12, 2026
  2. sivakumar-mahalingam commented on Oct 12, 2026

    @sivakumar-mahalingam
    ContributorAuthor

    take

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

type:bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions