Bug: S3RecordModel drops lifecycleEventData and replicationEventData
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Anfängerfreundlichkeit
- 82/100
Rechercherichtung
Lies zunächst S3RecordModel und die benachbarten Event-Datenfelder, sieh dir dann tests/events/s3EventLifecycleTransition.json und die Parser-Tests für S3-Datensätze an. Ergänze Tests dafür, dass beide Event-Datenfelder erhalten bleiben, einschließlich eines passenden Replikationsbeispiels. Fertig, wenn das Parsen von S3- und S3-to-SQS-Events die Daten beibehält und die relevanten Tests bestehen.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Expected Behaviour
S3RecordModel keeps lifecycleEventData and replicationEventData when S3 sends them, the same way it keeps glacierEventData and intelligentTieringEventData. They hold the main detail of those events, like the storage class an object moved to or why a replication failed. The event message structure docs list both, and there are samples for Lifecycle transition and replication events.
Current Behaviour
The model doesn't declare either key, and Pydantic ignores keys it doesn't know, so these events parse without an error but the data isn't on the parsed record. The repo's own tests/events/s3EventLifecycleTransition.json has lifecycleEventData, and it's gone after parsing. S3SqsEventNotificationModel reuses S3Model, so S3 to SQS events lose it too.
The TypeScript parser added both in aws-powertools/powertools-lambda-typescript#5924.
Code snippet
import json
from aws_lambda_powertools.utilities.parser import parse
from aws_lambda_powertools.utilities.parser.models import S3Model
with open("tests/events/s3EventLifecycleTransition.json") as f:
event = json.load(f)
print("in event:", "lifecycleEventData" in event["Records"][0])
record = parse(event=event, model=S3Model).Records[0]
print("on parsed record:", "lifecycleEventData" in record.model_dump())
in event: True
on parsed record: False
Possible Solution
Add both as optional fields next to intelligentTieringEventData, with Field(description=...) like the rest of the model:
class S3EventRecordLifecycleTransitionEventData(BaseModel):
destinationStorageClass: str
class S3EventRecordLifecycleEventData(BaseModel):
transitionEventData: S3EventRecordLifecycleTransitionEventData
class S3EventRecordReplicationEventData(BaseModel):
replicationRuleId: str | None = None
destinationBucket: str | None = None
s3Operation: str | None = None
requestTime: str | None = None
failureReason: str | None = None
# In S3RecordModel
lifecycleEventData: S3EventRecordLifecycleEventData | None = None
replicationEventData: S3EventRecordReplicationEventData | None = None
Every replication field is optional because the docs only show the failed replication event, the same call the TypeScript fix made. This only adds fields, so nothing that parses today changes.
I'm happy to send a PR with tests and a replication fixture if that sounds good.
Steps to Reproduce
Run the snippet above from the repo root. The replication sample from the docs page loses replicationEventData the same way.
Powertools for AWS Lambda (Python) version
3.40.0
AWS Lambda function runtime
3.13
Packaging format used
PyPi
- Vorherrschende Sprache
- Python
- Sterne
- 3.3k
- Forks
- 511
- Ø Merge
- 3 T. 8 Std.
- Gemergte PRs (30 T.)
- 103
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus aws-powertools/powertools-lambda-python
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
aws-powertools/powertools-lambda-python#8801 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Bug: child Logger without a level ignores its parent's log level since 3.6.0Evtl. vergeben @saimcyber hat das heute übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
aws-powertools/powertools-lambda-python#8778 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
Bug: POWERTOOLS_IDEMPOTENCY_DISABLED set to an empty or non-boolean value crashes every invocationEvtl. vergeben @lechakrawarthy hat das vor 11 Tagen übernommen. Offenbug good first issue help wanted idempotency
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 85/100
aws-powertools/powertools-lambda-python#8728 · 4 Kommentare · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 1 Tag
-
Bug: Redis layer fails the invocation instead of retrying when a record expires between SET NX and GETEvtl. vergeben @coughlmao hat das vor 11 Tagen übernommen. Offenbug good first issue help wanted idempotency
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 85/100
aws-powertools/powertools-lambda-python#8727 · 4 Kommentare · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 1 Tag
-
Bug: Redis orphan lock timeout ignores expires_after_seconds and is always 10 secondsEvtl. vergeben @CJstate hat das vor 11 Tagen übernommen. Offenbug good first issue help wanted idempotency
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
aws-powertools/powertools-lambda-python#8726 · 4 Kommentare · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in aws-powertools/powertools-lambda-python
Ähnliche Issues
-
15-minutes 5-minutes algorithm any-language beginner-friendly c cpp csharp easy go good first issue hacktoberfest help wanted java javascript kotlin python rust swift typescript
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Huerte/algo-solutions-python#254 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 1/5 1-3 Stunden Anfängerfreundlichkeit 86/100
MichaelYcJo/SpecSeal#1543 ·
-
size/s
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 90/100
sipyourdrink-ltd/bernstein#7179 ·
Maintainer antworten meist innerhalb von 1 Tag
-
good first issue help wanted python up-for-grabs
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
andrewsiah/agentswarm-data-tasks#309 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
Maintainer antworten meist innerhalb von 1 Tag