Skip to content

Fetching unknown profile returns 500 Internal Server Error #2480

Closed
@AElmecker

Description

@AElmecker

Observed Behavior

Fetching the profile for an unknown repository called foo:

GET http://localhost:8080/profile/foo

yields a 500 Internal Server Error with following response:

{
  "cause": null,
  "message": "Could not resolve repository metadata for foo."
}

The culprit seems to
be org.springframework.data.rest.webmvc.config.ResourceMetadataHandlerMethodArgumentResolver
throwing an IllegalArgumentException when it is not able to resolve the repository.

Expected Behavior

A 404 Not Found is returned like

{
  "timestamp": "2025-05-14T19:51:01.935+00:00",
  "status": 404,
  "error": "Not Found",
  "path": "/profile/foo"
}

Steps To Reproduce

I created a small reproducer with can be checked out in this repository, the readme there also contains a similar description as this issue.

  1. Start application
  2. Fetch profile for unknown repository
    curl -X GET --location "http://localhost:8080/profile/foo" -H "Accept: application/json"
  3. Retrieve 500 Internal Server Error

Spring Initializr Setup

  • Project: Gradle - Kotlin
  • Language: Java
  • Spring Boot: 3.4.5
  • Packaging: Jar
  • Java: 21
  • Dependencies
    • Spring Data JPA
    • Rest Repositories
    • H2 Database

Similar/Related issues

Some issue I already found that sounds similar is #2014, but that conversation came to an halt.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions