mirror of
https://github.com/floci-io/floci.git
synced 2026-11-24 06:20:24 -05:00
fix(rds): format unexpected query errors as XML error envelope (#3121)
* fix(rds): format unexpected query errors as XML error envelope Unhandled runtime exceptions in RdsQueryHandler and NeptuneQueryHandler previously returned plain text Response.serverError entities, causing AWS CLI and SDK XML parsers to fail with syntax errors. Wrap unexpected exceptions in AwsQueryResponse.error with InternalFailure and ensure 5xx status codes render with <Type>Receiver</Type> in accordance with AWS Query protocol specifications. Also add unit tests covering default platform image cache eviction and unexpected RDS handler errors. Closes #3110 * test(neptune): add unit tests for query handler error responses Verify NeptuneQueryHandler unexpected exceptions return an XML InternalFailure error response with HTTP 500 status and Receiver error type.
This commit is contained in:
1 parent
c0b5461f10
commit
daeea78ee6
6 files changed
+167
-3
No files matched your search
@@ -102,10 +102,21 @@ public final class AwsQueryResponse {
|
||||
* @param xmlns the namespace URI, or {@code null} for namespace-free error responses (e.g. SQS)
|
||||
*/
|
||||
public static Response error(String code, String message, String xmlns, int status) {
|
||||
String type = status >= 500 ? "Receiver" : "Sender";
|
||||
return error(code, message, xmlns, status, type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a Query-protocol XML error response with an explicit error type and returns a JAX-RS {@link Response}.
|
||||
*
|
||||
* @param xmlns the namespace URI, or {@code null} for namespace-free error responses (e.g. SQS)
|
||||
* @param type the error type, typically "Sender" for 4xx or "Receiver" for 5xx
|
||||
*/
|
||||
public static Response error(String code, String message, String xmlns, int status, String type) {
|
||||
String xml = new XmlBuilder()
|
||||
.start("ErrorResponse", xmlns)
|
||||
.start("Error")
|
||||
.elem("Type", "Sender")
|
||||
.elem("Type", type)
|
||||
.elem("Code", code)
|
||||
.elem("Message", message)
|
||||
.end("Error")
|
||||
|
||||
@@ -65,7 +65,8 @@ public class NeptuneQueryHandler {
|
||||
return AwsQueryResponse.error(e.getErrorCode(), e.getMessage(), AwsNamespaces.RDS, e.getHttpStatus());
|
||||
} catch (Exception e) {
|
||||
LOG.errorv(e, "Unexpected error in Neptune {0}", action);
|
||||
return Response.serverError().entity("Unexpected error: " + e.getMessage()).build();
|
||||
return AwsQueryResponse.error("InternalFailure",
|
||||
"Unexpected error: " + e.getMessage(), AwsNamespaces.RDS, 500);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -114,7 +114,8 @@ public class RdsQueryHandler {
|
||||
return AwsQueryResponse.error(e.getErrorCode(), e.getMessage(), AwsNamespaces.RDS, e.getHttpStatus());
|
||||
} catch (Exception e) {
|
||||
LOG.errorv(e, "Unexpected error in RDS {0}", action);
|
||||
return Response.serverError().entity("Unexpected error: " + e.getMessage()).build();
|
||||
return AwsQueryResponse.error("InternalFailure",
|
||||
"Unexpected error: " + e.getMessage(), AwsNamespaces.RDS, 500);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user