Skip to content

Unexpected error response data when mapping UnauthorizedException #6047

Open
@jsenko

Description

@jsenko

The auth error is expected, but I think the error response was intended to be limited only to the entity sub-field, and entity.status should be 401 instead of 500. Check if exception mapper works properly.

sh-4.4$ curl -vs -X POST -H 'content-type: application/json' --data '{"ruleType": "VALIDITY", "config": "FULL"}' http://simple-app-service.test-9081fec.svc.cluster.local:8080/apis/registry/v3/admin/rules | ./jq
*   Trying 172.30.159.203...
* TCP_NODELAY set
* Connected to simple-app-service.test-9081fec.svc.cluster.local (172.30.159.203) port 8080 (#0)
> POST /apis/registry/v3/admin/rules HTTP/1.1
> Host: simple-app-service.test-9081fec.svc.cluster.local:8080
> User-Agent: curl/7.61.1
> Accept: */*
> content-type: application/json
> Content-Length: 42
> 
} [42 bytes data]
* upload completely sent off: 42 out of 42 bytes
< HTTP/1.1 401 Unauthorized
< Date: Tue, 18 Mar 2025 12:42:30 GMT
< Expires: Mon, 17 Mar 2025 12:42:30 GMT
< Pragma: no-cache
< Cache-control: no-cache, no-store, must-revalidate
< Strict-Transport-Security: max-age=31536000; includeSubdomains
< Content-Type: application/json
< Content-Length: 754
< 
{ [754 bytes data]
* Connection #0 to host simple-app-service.test-9081fec.svc.cluster.local left intact
{
  "entity": {
    "detail": "UnauthorizedException: User is not authenticated.",
    "title": "User is not authenticated.",
    "status": 500,
    "name": "UnauthorizedException"
  },
  "status": 500,
  "metadata": {
    "Content-Type": [
      "application/json"
    ]
  },
  "annotations": null,
  "entityClass": "io.apicurio.registry.rest.v3.beans.ProblemDetails",
  "genericType": null,
  "length": -1,
  "location": null,
  "language": null,
  "date": null,
  "lastModified": null,
  "closed": false,
  "statusInfo": "INTERNAL_SERVER_ERROR",
  "reasonPhrase": "Unknown Code",
  "cookies": {},
  "links": [],
  "mediaType": {
    "type": "application",
    "subtype": "json",
    "parameters": {},
    "wildcardType": false,
    "wildcardSubtype": false
  },
  "allowedMethods": [],
  "entityTag": null,
  "stringHeaders": {
    "Content-Type": [
      "application/json"
    ]
  },
  "headers": {
    "Content-Type": [
      "application/json"
    ]
  }
}

Metadata

Metadata

Assignees

Type

Projects

Status

In Progress

Relationships

None yet

Development

No branches or pull requests

Issue actions