Skip to content

Accept the 500 body without the exception message in BuiltInEndpointsSpec - #2277

Merged
dstepanov merged 1 commit into
5.4.xfrom
builtin-endpoints-spec-error-message
Sep 11, 2026
Merged

Accept the 500 body without the exception message in BuiltInEndpointsSpec#2277
dstepanov merged 1 commit into
5.4.xfrom
builtin-endpoints-spec-error-message

Conversation

@dstepanov

@dstepanov dstepanov commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Part of micronaut-projects/micronaut-core#13110 (moving projects onto core 5.2).

Problem

On core 5.2.0, BuiltInEndpointsSpec fails every time on "test accessing a sensitive endpoint with authentication but no SensitiveEndpointRule replacement throws an exception":

m._embedded.errors == [[message: "Internal Server Error: ${SensitiveEndpointRule.NON_REPLACED_SECURITY_ERROR_MESSAGE}"]]
  [errors:[[message:Internal Server Error]]]

Core 5.2 added micronaut.server.error-response-include-message (never | always | on-param) in micronaut-core 05421f2708. It defaults to never, so RouteExecutor now renders a plain Internal Server Error for unhandled exceptions. The raw message stays in ErrorContext.getExceptionMessage() and in the server log.

Change

Test only. The spec now:

  • asserts the 500 status, which it did not check before, and
  • accepts either Internal Server Error (core 5.2 by default) or Internal Server Error: <message> (core 5.1).

I did not set micronaut.server.error-response-include-message: always in the spec. That setting is not recommended for production, and this spec is included in the docs. So the test should show how security behaves under the default setting.

SensitiveEndpointRule still rejects the request the same way. No main code or docs in security depend on the exception message being in the 500 body. The hint for NON_REPLACED_SECURITY_ERROR_MESSAGE is still logged by RouteExecutor.

Verification

  • Core 5.1.12 (current catalog): BuiltInEndpointsSpec passes before and after this change (2 tests). Full ./gradlew check --continue with this change: 1675 tests, 0 failures, 2 skipped.
  • Core 5.2.0 (catalog changed locally, not in this PR): BuiltInEndpointsSpec fails before this change and passes after it (2 tests). Full ./gradlew check --continue with this change: 1675 tests, 0 failures, 2 skipped.

Core version

This PR keeps micronaut = "5.1.12", so it can merge on its own. 5.4.x is at 5.4.0-SNAPSHOT and no v5.4.* is released, so the core 5.2 bump itself can also land on this branch in a separate PR. No new branch is needed.

🤖 Generated with Claude Code

…Spec

Micronaut Framework 5.2 adds micronaut.server.error-response-include-message,
which defaults to never, so the 500 response for a sensitive endpoint without a
SensitiveEndpointRule replacement now carries only "Internal Server Error". The
spec accepts that and the message form older cores render, and it now asserts
the 500 status.

See micronaut-projects/micronaut-core#13110

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

@dstepanov
dstepanov merged commit b5d633b into 5.4.x Sep 11, 2026
13 checks passed
@dstepanov
dstepanov deleted the builtin-endpoints-spec-error-message branch September 11, 2026 04:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants