Skip to content

BasicErrorController should align with spring.mvc.problemdetails.enabled to support RFC 9457? #48392

@ximinghui

Description

@ximinghui

Description

When RFC 9457 support is enabled via spring.mvc.problemdetails.enabled=true, there is an inconsistency in error response formats.

While exceptions handled by the Spring MVC infrastructure (via ResponseEntityExceptionHandler) correctly return the standard application/problem+json format, the error responses generated by BasicErrorController#error(HttpServletRequest) or DefaultErrorAttributes still return the legacy Spring Boot error format.

Observed Behavior

  1. ResponseEntityExceptionHandler returns RFC 9457 format:
{
  "type": "about:blank",
  "title": "Bad Request",
  "status": 400,
  "detail": "Invalid input",
  "instance": "/api/resource"
}
  1. BasicErrorController always returns the legacy format:
{
  "timestamp": "2023-10-27T10:00:00.000+00:00",
  "status": 404,
  "error": "Not Found",
  "path": "/api/non-existent"
}

Expected Behavior

When spring.mvc.problemdetails.enabled is set to true, the BasicErrorController (or DefaultErrorAttributes) should also produce a response body that adheres to the RFC 9457 Problem Details specification?

Are there plans to update BasicErrorController to natively support spring.mvc.problemdetails.enabled?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions