Skip to content

Custom reason is overwritten by i18n message in ResponseStatusException.updateAndGetBody() #36984

Closed

Description

@UserMist

In cases where reason on ResponseStatusException is not manually set, I expect localization key equal to problemDetail.org.springframework.web.server.ResponseStatusException to act as a fallback; but since super.updateAndGetBody() is called before instead of after custom logic, this localization acts as an overwrite instead.

Activity

  1. Mhmoud803 commented on Jun 30, 2026

    @Mhmoud803

    Hi team! I think I've spotted the issue here—it looks like the call to super.updateAndGetBody() is overriding the custom logic. Reordering this should resolve the fallback issue, and I’d be happy to put together a PR if you're open to it!

  2. added
    in: webIssues in web modules (web, webmvc, webflux, websocket)
    on Sep 19, 2026
  3. changed the title [-]Wrong localization order in ResponseStatusException.updateAndGetBody()[/-] [+]Custom reason is overwritten by i18n message in ResponseStatusException.updateAndGetBody()[/+] on Sep 22, 2026
  4. added and removed on Sep 22, 2026
  5. self-assigned this
    on Sep 22, 2026
  6. bclozel commented on Sep 22, 2026

    @bclozel
    Member

    After having a proper look, I don't think reordering is enough. Taking a step back, the main problem is that the order of preference for the detail message is not strictly enforced; it should be:

    1. If a custom reason is defined, it should be used
    2. if the reason is a message code and it can be resolved, we should use
    3. if no reason is provided, we should use the message resolved from the default message code

    The issue here is that ResponseStatusException#updateAndGetBody can override custom reason messages and only 2 and 3 are covered.

  7. added this to the 7.0.10 milestone on Sep 22, 2026
  8. github-actions commented on Sep 22, 2026

    @github-actions
    Contributor

    Fixed via 7be3a61

  9. added a commit that references this issue on Sep 22, 2026
    7be3a61
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: bugA general bug

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions