AN-796 Fix Swagger UI 500 errors #7822
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
…s (#7763)
This commit fixes Issue #7763 where reloading the Swagger UI page causes intermittent 500 Internal Server Error responses with the message: "requirement failed: Responses with this status code must have an empty entity"
Root Cause:
Akka HTTP 10.1.15's
getFromResourcemethod returns 304 Not Modified responses with non-empty entities, which violates RFC 7232 Section 4.1. The issue is triggered whenmapResponseEntityattempts to transform the entity content (replacing Swagger URLs), causing HttpResponse validation to fail because 304 responses must have empty entities.The error was particularly visible in Chrome-based browsers when using the refresh button (Ctrl+R/F5), as Chrome sends conditional requests (If-None-Match headers) even with Cache-Control: no-cache.
Solution:
Intercept the response from
getFromResourcebefore any entity transformation. Check if the status is 304 Not Modified and ensure the entity is empty before attempting any content transformation. For 200 OK responses, apply the normal URL replacement logic.Changes made in SwaggerUiHttpService.scala:
Modified serveIndex method (lines 26-46):
Fixes #7763
Description
Release Notes Confirmation
CHANGELOG.mdCHANGELOG.mdin this PRCHANGELOG.mdbecause it doesn't impact community usersTerra Release Notes