From f735c135a8cab0fd0b001efd800774b385cbcc88 Mon Sep 17 00:00:00 2001 From: Binary Alley Date: Fri, 20 Nov 2026 10:38:15 +0200 Subject: [PATCH] Updates ProblemDetails references to current RFCs Points the 500 problem type at RFC 9110 section 15.6.1, points 429 at RFC 6585 section 4, documents ProblemDetailsDto as RFC 9457, and aligns the 429 OpenAPI examples with the runtime detail codes. Adds an assertion for the middleware problem type so it cannot regress silently. --- .../DependencyInjection/PresentationApiLayerServices.cs | 2 +- .../Common/Middlewares/ExceptionHandlingMiddleware.cs | 2 +- .../Authentication/Login/LoginEndpointSummary.cs | 4 ++-- .../RecoverPassword/RecoverPasswordEndpointSummary.cs | 4 ++-- .../Authentication/Register/RegisterEndpointSummary.cs | 4 ++-- .../Common/DTO/Common/ProblemDetailsDto.cs | 2 +- .../UsersManagement/Authentication/LoginEndpointTests.cs | 2 +- .../Authentication/RecoverPasswordEndpointTests.cs | 2 +- .../UsersManagement/Authentication/RegisterEndpointTests.cs | 2 +- .../Common/Middlewares/ExceptionHandlingMiddlewareTests.cs | 1 + 10 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/Lumina.Presentation.Api/Common/DependencyInjection/PresentationApiLayerServices.cs b/src/Lumina.Presentation.Api/Common/DependencyInjection/PresentationApiLayerServices.cs index ed229315..f8587ae3 100644 --- a/src/Lumina.Presentation.Api/Common/DependencyInjection/PresentationApiLayerServices.cs +++ b/src/Lumina.Presentation.Api/Common/DependencyInjection/PresentationApiLayerServices.cs @@ -96,7 +96,7 @@ public static class PresentationApiLayerServices var problem = new { - type = "https://tools.ietf.org/html/rfc7231#section-6.5.29", + type = "https://tools.ietf.org/html/rfc6585#section-4", title = "TooManyRequests", status = StatusCodes.Status429TooManyRequests, detail = "TooManyRequests", diff --git a/src/Lumina.Presentation.Api/Common/Middlewares/ExceptionHandlingMiddleware.cs b/src/Lumina.Presentation.Api/Common/Middlewares/ExceptionHandlingMiddleware.cs index ec7ac12a..ea25fb14 100644 --- a/src/Lumina.Presentation.Api/Common/Middlewares/ExceptionHandlingMiddleware.cs +++ b/src/Lumina.Presentation.Api/Common/Middlewares/ExceptionHandlingMiddleware.cs @@ -66,7 +66,7 @@ public class ExceptionHandlingMiddleware { ProblemDetails problemDetails = new() { - Type = "https://tools.ietf.org/html/rfc7231#section-6.6.1", + Type = "https://tools.ietf.org/html/rfc9110#section-15.6.1", Title = "InternalServerError", Status = StatusCodes.Status500InternalServerError, Detail = "An unexpected error occurred while processing the request.", diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/UsersManagement/Authentication/Login/LoginEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/UsersManagement/Authentication/Login/LoginEndpointSummary.cs index 25f1bfb8..a6adaad8 100644 --- a/src/Lumina.Presentation.Api/Core/Endpoints/UsersManagement/Authentication/Login/LoginEndpointSummary.cs +++ b/src/Lumina.Presentation.Api/Core/Endpoints/UsersManagement/Authentication/Login/LoginEndpointSummary.cs @@ -83,10 +83,10 @@ public class LoginEndpointSummary : Summary Response(429, "The request failed due to a more than 10 requests to this endpoint in less than 15 minutes.", "application/problem+json", example: new { - type = "https://tools.ietf.org/html/rfc7231#section-6.5.29", + type = "https://tools.ietf.org/html/rfc6585#section-4", title = "TooManyRequests", status = 429, - detail = "Too many attempts. Please try again later.", + detail = "TooManyRequests", retryAfter = "900" } ); diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/UsersManagement/Authentication/RecoverPassword/RecoverPasswordEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/UsersManagement/Authentication/RecoverPassword/RecoverPasswordEndpointSummary.cs index ac823e70..28e42764 100644 --- a/src/Lumina.Presentation.Api/Core/Endpoints/UsersManagement/Authentication/RecoverPassword/RecoverPasswordEndpointSummary.cs +++ b/src/Lumina.Presentation.Api/Core/Endpoints/UsersManagement/Authentication/RecoverPassword/RecoverPasswordEndpointSummary.cs @@ -85,10 +85,10 @@ public class RecoverPasswordEndpointSummary : Summary -/// Data transfer object that follows the RFC 7807 standard for problem details in HTTP APIs. +/// Data transfer object that follows the RFC 9457 standard for problem details in HTTP APIs. /// [DebuggerDisplay("{Title} ({Status})")] public class ProblemDetailsDto diff --git a/tests/SecurityTests/Lumina.Presentation.Api.SecurityTests/Core/Endpoints/UsersManagement/Authentication/LoginEndpointTests.cs b/tests/SecurityTests/Lumina.Presentation.Api.SecurityTests/Core/Endpoints/UsersManagement/Authentication/LoginEndpointTests.cs index 680cc39f..bad43468 100644 --- a/tests/SecurityTests/Lumina.Presentation.Api.SecurityTests/Core/Endpoints/UsersManagement/Authentication/LoginEndpointTests.cs +++ b/tests/SecurityTests/Lumina.Presentation.Api.SecurityTests/Core/Endpoints/UsersManagement/Authentication/LoginEndpointTests.cs @@ -167,7 +167,7 @@ public class LoginEndpointTests : IClassFixture, IDisposable Dictionary? problemDetails = JsonSerializer.Deserialize>(content, _jsonOptions); Assert.NotNull(problemDetails); Assert.Equal(StatusCodes.Status429TooManyRequests, problemDetails!["status"].GetInt32()); - Assert.Equal("https://tools.ietf.org/html/rfc7231#section-6.5.29", problemDetails["type"].GetString()); + Assert.Equal("https://tools.ietf.org/html/rfc6585#section-4", problemDetails["type"].GetString()); Assert.Equal("TooManyRequests", problemDetails["title"].GetString()); Assert.Equal("TooManyRequests", problemDetails["detail"].GetString()); Assert.Equal("900", problemDetails["retryAfter"].GetString()); diff --git a/tests/SecurityTests/Lumina.Presentation.Api.SecurityTests/Core/Endpoints/UsersManagement/Authentication/RecoverPasswordEndpointTests.cs b/tests/SecurityTests/Lumina.Presentation.Api.SecurityTests/Core/Endpoints/UsersManagement/Authentication/RecoverPasswordEndpointTests.cs index a4b98367..63a4a07a 100644 --- a/tests/SecurityTests/Lumina.Presentation.Api.SecurityTests/Core/Endpoints/UsersManagement/Authentication/RecoverPasswordEndpointTests.cs +++ b/tests/SecurityTests/Lumina.Presentation.Api.SecurityTests/Core/Endpoints/UsersManagement/Authentication/RecoverPasswordEndpointTests.cs @@ -77,7 +77,7 @@ public class RecoverPasswordEndpointTests : IClassFixture, IDi Dictionary? problemDetails = JsonSerializer.Deserialize>(content, _jsonOptions); Assert.NotNull(problemDetails); Assert.Equal(StatusCodes.Status429TooManyRequests, problemDetails!["status"].GetInt32()); - Assert.Equal("https://tools.ietf.org/html/rfc7231#section-6.5.29", problemDetails["type"].GetString()); + Assert.Equal("https://tools.ietf.org/html/rfc6585#section-4", problemDetails["type"].GetString()); Assert.Equal("TooManyRequests", problemDetails["title"].GetString()); Assert.Equal("TooManyRequests", problemDetails["detail"].GetString()); Assert.Equal("900", problemDetails["retryAfter"].GetString()); diff --git a/tests/SecurityTests/Lumina.Presentation.Api.SecurityTests/Core/Endpoints/UsersManagement/Authentication/RegisterEndpointTests.cs b/tests/SecurityTests/Lumina.Presentation.Api.SecurityTests/Core/Endpoints/UsersManagement/Authentication/RegisterEndpointTests.cs index 5b41c30d..7b499168 100644 --- a/tests/SecurityTests/Lumina.Presentation.Api.SecurityTests/Core/Endpoints/UsersManagement/Authentication/RegisterEndpointTests.cs +++ b/tests/SecurityTests/Lumina.Presentation.Api.SecurityTests/Core/Endpoints/UsersManagement/Authentication/RegisterEndpointTests.cs @@ -95,7 +95,7 @@ public class RegisterEndpointTests : IClassFixture, IDisposabl Dictionary? problemDetails = JsonSerializer.Deserialize>(content, _jsonOptions); Assert.NotNull(problemDetails); Assert.Equal(StatusCodes.Status429TooManyRequests, problemDetails!["status"].GetInt32()); - Assert.Equal("https://tools.ietf.org/html/rfc7231#section-6.5.29", problemDetails["type"].GetString()); + Assert.Equal("https://tools.ietf.org/html/rfc6585#section-4", problemDetails["type"].GetString()); Assert.Equal("TooManyRequests", problemDetails["title"].GetString()); Assert.Equal("TooManyRequests", problemDetails["detail"].GetString()); Assert.Equal("900", problemDetails["retryAfter"].GetString()); diff --git a/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Common/Middlewares/ExceptionHandlingMiddlewareTests.cs b/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Common/Middlewares/ExceptionHandlingMiddlewareTests.cs index a273e912..819e0d03 100644 --- a/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Common/Middlewares/ExceptionHandlingMiddlewareTests.cs +++ b/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Common/Middlewares/ExceptionHandlingMiddlewareTests.cs @@ -58,6 +58,7 @@ public class ExceptionHandlingMiddlewareTests string responseBody = await reader.ReadToEndAsync(); ProblemDetails problemDetails = JsonSerializer.Deserialize(responseBody, _jsonOptions)!; Assert.Equal(StatusCodes.Status500InternalServerError, problemDetails.Status); + Assert.Equal("https://tools.ietf.org/html/rfc9110#section-15.6.1", problemDetails.Type); Assert.Equal("InternalServerError", problemDetails.Title); Assert.Equal("An unexpected error occurred while processing the request.", problemDetails.Detail); Assert.False(string.IsNullOrEmpty(problemDetails.Extensions["traceId"]?.ToString()));