InvalidMessageContents
aws
config_error
ai_generated
true
调用SendMessage操作时发生错误(InvalidMessageContents):消息属性是必需的但缺失
An error occurred (InvalidMessageContents) when calling the SendMessage operation: Message attributes are required but missing
ID: aws/sqs-message-attributes-missing
82%修复率
84%置信度
1证据数
2023-10-05首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| SQS 2012-11-05 | active | — | — | — |
| AWS CLI 2.13.0 | active | — | — | — |
| Lambda 2023-08-01 | active | — | — | — |
根因分析
SQS队列配置了期望特定消息属性的策略或Lambda触发器,但发送的消息不包含这些属性。
English
The SQS queue is configured with a policy or a Lambda trigger that expects specific message attributes, but the sent message does not include them.
官方文档
https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_SendMessage.html解决方案
-
发送消息时包含必需的消息属性。使用AWS CLI: aws sqs send-message --queue-url https://sqs.us-east-1.amazonaws.com/123456789012/my-queue --message-body "Hello" --message-attributes "{\"AttributeName\":{\"DataType\":\"String\",\"StringValue\":\"Value\"}}" -
检查队列策略或Lambda事件源映射以识别必需的属性: aws sqs get-queue-attributes --queue-url https://sqs.us-east-1.amazonaws.com/123456789012/my-queue --attribute-names Policy # 审查策略中关于消息属性的条件。
-
如果可行,修改Lambda触发器或队列策略使属性变为可选: # 示例:从策略中移除要求'AttributeName'的条件 aws sqs set-queue-attributes --queue-url https://sqs.us-east-1.amazonaws.com/123456789012/my-queue --attributes Policy='{"Version":"2012-10-17","Statement":[]}'
无效尝试
常见但无效的做法:
-
Recreate the SQS queue with default settings
90% 失败
Recreating the queue does not change the requirement for message attributes; the Lambda trigger or policy still expects them.
-
Send an empty message body
95% 失败
The error is about missing message attributes, not the body; an empty body does not resolve the attribute requirement.
-
Increase the message retention period
98% 失败
Retention period does not affect message contents or attribute validation.