Bug: SQSRecord.decoded_nested_sns_event raises KeyError on SNS messages delivered to SQS
Los mantenedores suelen responder en 1 día
@hyeonsang010716 ya está trabajando en esto.
Desde el 26/11/2026.
- #8914 de @hyeonsang010716 — abierto
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 79/100
Línea de trabajo
Empieza leyendo SNSMessage y la prueba existente test_decode_nested_sns_event; después, inspecciona tests/events/snsSqsEvent.json y tests/events/snsSqsFifoEvent.json. Añade cobertura para las propiedades opcionales enumeradas y las grafías alternativas de las claves, usando como resultado esperado el comportamiento propuesto en el issue. El trabajo estará terminado cuando las pruebas confirmen que los mensajes SNS entregados por SQS exponen estas propiedades sin KeyError, mientras que los valores de los eventos SNS de Lambda permanecen sin cambios.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Expected Behaviour
SQSRecord.decoded_nested_sns_event returns an SNSMessage whose properties work on the message SNS sends to SQS, the same way the SnsNotificationModel parser model and SnsSqsEnvelope already handle it (#272, #1299, #1606).
Current Behaviour
SNSMessage only reads the keys of the Lambda SNS event (Records[].Sns). The SNS message in an SQS body is different:
- It uses
UnsubscribeURLandSigningCertURLinstead ofUnsubscribeUrlandSigningCertUrl, as in the SNS to SQS example. - It leaves out
SubjectandMessageAttributeswhen they are not set. - For FIFO topics with content-based deduplication it has no
Signature,SignatureVersionorSigningCertURL(payload in #1590).
So unsubscribe_url, signing_cert_url, subject and message_attributes raise KeyError on tests/events/snsSqsEvent.json, and signature and signature_version also raise on tests/events/snsSqsFifoEvent.json. The existing test_decode_nested_sns_event doesn't read these properties.
Code snippet
import json
from aws_lambda_powertools.utilities.data_classes import SQSEvent
# Body of an SQS message that an SNS topic delivered (raw message delivery disabled)
sns_body = {
"Type": "Notification",
"MessageId": "95df01b4-ee98-5cb9-9903-4c221d41eb5e",
"TopicArn": "arn:aws:sns:eu-west-1:123456789012:orders",
"Message": "hello world",
"Timestamp": "2026-11-26T10:00:00.000Z",
"SignatureVersion": "1",
"Signature": "EXAMPLEpH+..",
"SigningCertURL": "https://sns.eu-west-1.amazonaws.com/SimpleNotificationService-0000000000000000000000.pem",
"UnsubscribeURL": "https://sns.eu-west-1.amazonaws.com/?Action=Unsubscribe&SubscriptionArn=arn:aws:sns:eu-west-1:123456789012:orders:0000",
}
event = SQSEvent({"Records": [{"messageId": "1", "body": json.dumps(sns_body), "eventSource": "aws:sqs"}]})
sns_message = next(event.records).decoded_nested_sns_event
for prop in ("unsubscribe_url", "signing_cert_url", "subject", "message_attributes"):
try:
print(f"{prop}: {getattr(sns_message, prop)!r}")
except KeyError as exc:
print(f"{prop}: KeyError {exc}")
Output:
unsubscribe_url: KeyError 'UnsubscribeUrl'
signing_cert_url: KeyError 'SigningCertUrl'
subject: KeyError 'Subject'
message_attributes: KeyError 'MessageAttributes'
Possible Solution
In SNSMessage, read both spellings for unsubscribe_url and signing_cert_url, return None from subject, signature, signature_version and signing_cert_url when the key is missing, and an empty dict from message_attributes. This matches the optional fields of SnsNotificationModel. The Lambda SNS event keeps returning the same values.
Steps to Reproduce
- Subscribe an SQS queue to an SNS topic, with raw message delivery disabled.
- Read
record.decoded_nested_sns_event.unsubscribe_urlin a Lambda function triggered by the queue, or run the snippet above. - It raises
KeyError: 'UnsubscribeUrl'.
Did you run the reproduction yourself?
Yes, I ran it and saw the failure
Powertools for AWS Lambda (Python) version
3.41.0
AWS Lambda function runtime
3.14
Packaging format used
PyPi
Debugging logs
- Lenguaje dominante
- Python
- Estrellas
- 3.3k
- Forks
- 511
- Merge medio
- 2 d 23 h
- PR fusionados (30 d)
- 50
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de aws-powertools/powertools-lambda-python
-
Bug: CaseInsensitiveDict (event.headers) returns True for both == and != against the same mappingAbiertobug triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
aws-powertools/powertools-lambda-python#8948 ·
Los mantenedores suelen responder en 1 día
-
Docs: child Logger without a parent uses the root log level since #8842Posiblemente ocupada @rdxrahul12 la tomó hoy. Abiertodocumentation triage
Dificultad 1/5 1-3 horas Aptitud para principiantes 85/100
aws-powertools/powertools-lambda-python#8935 · 3 comentarios ·
Los mantenedores suelen responder en 1 día
-
Bug: Set-Cookie values passed as a header are comma-joined into one invalid header on HTTP API and Function URL responsesPosiblemente ocupada @saquibjawedbit la tomó hace 4 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
aws-powertools/powertools-lambda-python#8921 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
Bug: validate() raises raw jmespath ParseError instead of InvalidEnvelopeExpressionError for most malformed envelopesPosiblemente ocupada @0x5t4l1n la tomó hoy. Abiertobug triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
aws-powertools/powertools-lambda-python#8918 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
Bug: Metrics keeps dimensions and metadata from an invocation that added no metricsPosiblemente ocupada @hyeonsang010716 la tomó hace 7 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 79/100
aws-powertools/powertools-lambda-python#8911 ·
Los mantenedores suelen responder en 1 día
Todos los issues de aws-powertools/powertools-lambda-python
Issues similares
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
litestar-org/sqlspec#946 ·
Los mantenedores suelen responder en 1 día
-
area:cli area:docs Platform vdr
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
NVIDIA-NeMo/Gym#7192 ·
Los mantenedores suelen responder en 2 días
-
SofyaBotAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
ai-robots-txt/ai.robots.txt#324 ·
-
[Resource]: DashbarAbiertoresource-submission validation-passed
Dificultad 1/5 Menos de una hora Aptitud para principiantes 78/100
hesreallyhim/awesome-claude-code#3821 · 1 comentario ·
-
bug good first issue help wanted level 1 wocs
Dificultad 2/5 1-3 horas Aptitud para principiantes 92/100
GianlucaBave/murmury#169 ·
Los mantenedores suelen responder en 1 día