Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't add AWSTraceHeader as system attribute because is replaced with "null" #1262

Closed
acomofcg opened this issue Oct 28, 2024 · 6 comments
Closed
Labels
component: sqs SQS integration related issue type: bug Something isn't working

Comments

@acomofcg
Copy link
Contributor

acomofcg commented Oct 28, 2024

Type: Bug

Component:
"SQS"

Describe the bug
In Spring Cloud 3.1.1 I can't send the MessageSystemAttribute AWSTraceHeader: when setting the attribute, in the system attribute map of software.amazon.awssdk.services.sqs.model.Message object, the key is replaced with "null" string when converted to SendMessageRequest, and SQS return 400.

Debugging the code, I found that the problem is the SqsTemplate class when converting MessageSystemAttributeName into MessageSystemAttributeNameForSends, method mapMessageSystemAttributes at line 457.

Possible fixes:

replace

MessageSystemAttributeNameForSends.fromValue(entry.getKey().name())

with

MessageSystemAttributeNameForSends.fromValue(entry.getKey().toString())

or

MessageSystemAttributeNameForSends.valueOf(entry.getKey().name())

What happening now is that the system attribute sent is

"null" -> "Root=1-c29f4bf9-2c45b3e36f5984be173ddfaf;Parent=5b48b4b16bff358a;Sampled=1"

instead of

"AWSTraceHeader" -> "Root=1-c29f4bf9-2c45b3e36f5984be173ddfaf;Parent=5b48b4b16bff358a;Sampled=1"

which is rejected by AWS.

@maciejwalkowiak maciejwalkowiak added type: bug Something isn't working component: sqs SQS integration related issue labels Oct 28, 2024
@maciejwalkowiak
Copy link
Contributor

@tomazfernandes could you take a look?

@acomofcg
Copy link
Contributor Author

acomofcg commented Nov 8, 2024

Hi @maciejwalkowiak @tomazfernandes any news on this?

@maciejwalkowiak
Copy link
Contributor

@acomofcg not yet. If you would like to contribute fix, PRs welcome!

@tomazfernandes
Copy link
Contributor

@acomofcg, thanks for bringing this up.

I wonder why this fails for this particular attribute and not the other ones?

Thanks

@acomofcg
Copy link
Contributor Author

Hi @tomazfernandes,

as far as I understand, the tracing header is the only attribute allowed to be used among system attributes, which is not mixed with the "normal" message attributes. This is why MessageSystemAttributeNameForSends has only one allowed value I guess.

Thanks for your help.

@acomofcg
Copy link
Contributor Author

Hi @tomazfernandes @maciejwalkowiak I opened a PR (#1287) for fixing the problem.

Please let me know if the tests are enough

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: sqs SQS integration related issue type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants