Skip to content

Add X-Amzn-Query-Error for error responses in JSON protocol#1191

Merged
micossow merged 1 commit intomasterfrom
1188-x-amzn-query-error
Feb 14, 2026
Merged

Add X-Amzn-Query-Error for error responses in JSON protocol#1191
micossow merged 1 commit intomasterfrom
1188-x-amzn-query-error

Conversation

@micossow
Copy link
Contributor

@micossow micossow commented Feb 14, 2026

closes #1188

@micossow micossow requested a review from Copilot February 14, 2026 14:40
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds the X-Amzn-Query-Error header to error responses when using the JSON protocol (AWS JSON Protocol 1.0) in ElasticMQ's SQS REST API implementation. This header provides the error type to clients, which aligns with AWS SQS behavior for JSON protocol error responses.

Changes:

  • Added custom header implementation X-Amzn-Query-Error for Pekko HTTP
  • Modified error handling to include the header for JSON protocol error responses
  • XML protocol (AWSQueryProtocol) error responses remain unchanged

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +24 to +27
case _ =>
respondWithHeader(`X-Amzn-Query-Error`(e.errorType)) {
complete(e.httpStatusCode, ErrorResponse(e.errorType, e.message))
}
Copy link

Copilot AI Feb 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new X-Amzn-Query-Error header added for JSON protocol error responses is not covered by any tests. Consider adding test coverage to verify that:

  1. The header is present in JSON protocol error responses
  2. The header contains the correct error type value
  3. The header is NOT present in XML protocol (AWSQueryProtocol) error responses

Example test location: rest/rest-sqs/src/test/scala/org/elasticmq/rest/sqs/directives/UnmatchedActionRoutesTest.scala already tests JSON protocol errors at line 66-69, and could be extended to check for the presence of this header.

Copilot uses AI. Check for mistakes.
Comment on lines +24 to +27
case _ =>
respondWithHeader(`X-Amzn-Query-Error`(e.errorType)) {
complete(e.httpStatusCode, ErrorResponse(e.errorType, e.message))
}
Copy link

Copilot AI Feb 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pattern matching uses a catch-all case _ which will apply the X-Amzn-Query-Error header to any non-AWSQueryProtocol case. While this currently only matches AWSJsonProtocol1.0, consider being explicit about which protocols should receive this header to prevent unintended behavior if additional protocols are added in the future.

Alternative approach: Use an explicit match case for AWSProtocol.AWSJsonProtocol1.0 instead of the catch-all pattern.

Suggested change
case _ =>
respondWithHeader(`X-Amzn-Query-Error`(e.errorType)) {
complete(e.httpStatusCode, ErrorResponse(e.errorType, e.message))
}
case AWSProtocol.`AWSJsonProtocol1.0` =>
respondWithHeader(`X-Amzn-Query-Error`(e.errorType)) {
complete(e.httpStatusCode, ErrorResponse(e.errorType, e.message))
}
case _ =>
complete(e.httpStatusCode, ErrorResponse(e.errorType, e.message))

Copilot uses AI. Check for mistakes.
@micossow micossow merged commit ea05d03 into master Feb 14, 2026
29 checks passed
@micossow micossow deleted the 1188-x-amzn-query-error branch February 14, 2026 14:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Missing 'x-amzn-query-error' header in JSON error responses causes TypeError in AWS SDK v3

2 participants