{"id":15294737,"url":"https://github.com/t1/problem-details","last_synced_at":"2025-04-13T14:53:55.316Z","repository":{"id":57723473,"uuid":"227818515","full_name":"t1/problem-details","owner":"t1","description":"Problem Details [RFC-9457] Java API, TCK, and implementations for JAX-RS and (currently not) Spring Boot","archived":false,"fork":false,"pushed_at":"2024-10-21T16:04:14.000Z","size":556,"stargazers_count":16,"open_issues_count":13,"forks_count":5,"subscribers_count":3,"default_branch":"trunk","last_synced_at":"2024-10-22T10:57:36.722Z","etag":null,"topics":["jax-rs","microprofile","microprofile-restclient","rfc-7807","rfc7807","spring-boot"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/t1.png","metadata":{"files":{"readme":"README.adoc","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-12-13T10:51:01.000Z","updated_at":"2024-10-21T16:04:16.000Z","dependencies_parsed_at":"2023-02-16T08:15:54.183Z","dependency_job_id":"e2e07c08-c337-4b4c-97d8-f36e0e373e77","html_url":"https://github.com/t1/problem-details","commit_stats":{"total_commits":253,"total_committers":3,"mean_commits":84.33333333333333,"dds":0.541501976284585,"last_synced_commit":"31355a25a8ac5d349381b25243164792992a24e6"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/t1%2Fproblem-details","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/t1%2Fproblem-details/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/t1%2Fproblem-details/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/t1%2Fproblem-details/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/t1","download_url":"https://codeload.github.com/t1/problem-details/tar.gz/refs/heads/trunk","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240093135,"owners_count":19746774,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["jax-rs","microprofile","microprofile-restclient","rfc-7807","rfc7807","spring-boot"],"created_at":"2024-09-30T17:06:32.805Z","updated_at":"2025-02-23T15:31:46.888Z","avatar_url":"https://github.com/t1.png","language":"Java","funding_links":[],"categories":["REST错误处理"],"sub_categories":["Spring Cloud框架"],"readme":"= Problem Detail image:https://maven-badges.herokuapp.com/maven-central/com.github.t1/problem-details/badge.svg[link=https://search.maven.org/artifact/com.github.t1/problem-details] image:https://github.com/t1/problem-details/actions/workflows/maven.yml/badge.svg[link=https://github.com/t1/problem-details/actions/workflows/maven.yml]\n\n== Abstract\n\nMap standard and custom exceptions to a http response body containing problem details as specified in https://datatracker.ietf.org/doc/html/rfc9457[RFC-9457] (formerly https://datatracker.ietf.org/doc/html/rfc7807[RFC-7807]).\n\nMost things work out of the box: the `type` and `title` fields are derived from the exception class name; the `detail` field is the message of the exception; the `instance` field is a random UUID URN that is also logged together with the complete stack trace.\n\nThese defaults and the status code can be overridden with annotations.\n\nI wrote a https://www.codecentric.de/wissens-hub/blog/rfc-7807-problem-details-with-spring-boot-and-jax-rs[blog] about this.\n\n== Motivation\n\nGetting a consistent error response format for a REST API is a common problem and allows clients to handle specific business errors. Getting some generic HTML response is not helpful. There is a standard for this type of details about an error: RFC-9457. And this library provides a simple way to map exceptions to this format.\n\n== Spec \u0026 API\n\nThis has been proposed to and rejected by several existing specs:\n\n* https://github.com/jakartaee/rest/issues/839[Jakarta REST (JAX-RS)]; a second discussion was also https://github.com/jakartaee/rest/issues/1150[rejected].\n* https://github.com/eclipse/microprofile-rest-client/issues/248[MP REST Client].\n\nThe API in the `api` module looks quite stable. Some first ideas for a full spec follow below. It's yet far from complete, but it's a start:\n\n* MUST `application/problem+json`, `application/problem+xml`; SHOULD any, e.g. `+yaml`\n* SHOULD render `text/html`\n* map also `@Valid` REST params\n* logging: 4xx = DEBUG, 5xx = ERROR; configurable?\n* order of extensions is alphabetic (which is better for tests than random)\n* multiple extensions with the same name: undefined behavior\n* JAXB can't unmarshal a subclass with the same type and namespace\n* Security considerations: nothing dangerous in problem details (i.e. exception message); stack-trace in logs\n* TODO scan client classpath for @Type annotated exceptions (and document this in the spec and the annotation)\n* TODO inherited annotations\n* TODO cause annotations\n* TODO type factory, e.g. URL to OpenAPI\n* TODO instance factory, e.g. URL to the logging system filtering on an UUID\n\n== Dummy-Impl [ri]\n\nIt's called `ri`, but it's actually only a POC, and it's incomplete. See the README for details.\n\n== Test\n\nThe `test` module runs integration tests by using https://github.com/t1/jee-testcontainers[JEE Testcontainers], i.e. it can be configured to start different Docker containers with various JEE application servers. By default, it starts a Wildfly.\n\n`testcontainer-running`\n\nAs the containers don't yet implement the API by themselves, the dummy implementation `ri` is hard-wired in the tests for now.\n\n=== Wildfly\n\nDefault `mvn` or explicitly `mvn -Djee-testcontainer=wildfly`\n\n=== Open Liberty\n\n`mvn -Djee-testcontainer=open-liberty:19.0.0.9-javaee8-java11 -Pwith-slf4j`\n\nneeds tag for jdk11 support\nneeds dependencies on slf4j-api and slf4j-jdk14\n\n=== TomEE\n\n`mvn -Djee-testcontainer=tomee`\n\n3 tests fail, because this version of TomEE (9.0.20 / 8.0.0-M3) doesn't write the problem detail response entity in some cases for some reason:\nStandardExceptionMappingIT.shouldMapWebApplicationExceptionWithoutEntityButMessage\nStandardExceptionMappingIT.shouldMapWebApplicationExceptionWithoutEntityOrMessage\nValidationFailedExceptionMappingIT.shouldMapValidationFailedException\n\n=== Payara\n\n`mvn -Djee-testcontainer=payara -Pwith-slf4j`\n\nfails due to lack of jdk11 support of the https://hub.docker.com/r/payara/server-full[`payara`] image.\nneeds dependencies on slf4j-api and slf4j-jdk14\n\n== Spring\n\nWe build for JDK 11 and the Jakarta EE 10 APIs. The current versions of Spring Boot don't support this combination. But you can still use the older `com.github.t1:problem-details-api:1.0.10`, which was based on Jakarta EE 8.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ft1%2Fproblem-details","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ft1%2Fproblem-details","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ft1%2Fproblem-details/lists"}