Bug: S3RecordModel drops lifecycleEventData and replicationEventData
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
先阅读 S3RecordModel 和相邻的事件数据字段,然后检查 tests/events/s3EventLifecycleTransition.json 以及 S3 记录的解析器测试。添加测试覆盖,确保两个事件数据字段都得到保留,并包含适当的复制示例。完成标准是解析 S3 和 S3-to-SQS 事件时保留数据,且相关测试通过。
由索引模型根据 Issue 内容生成。
描述
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
- 主要语言
- Python
- 星标
- 3.3k
- 派生
- 511
- 平均合并
- 3 天 8 小时
- 30 天内合并 PR
- 103
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
aws-powertools/powertools-lambda-python 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
aws-powertools/powertools-lambda-python#8801 ·
维护者通常 1 天内回复
-
Bug: child Logger without a level ignores its parent's log level since 3.6.0可能已有人在做 @saimcyber 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 68/100
aws-powertools/powertools-lambda-python#8778 · 2 条评论 ·
维护者通常 1 天内回复
-
Bug: POWERTOOLS_IDEMPOTENCY_DISABLED set to an empty or non-boolean value crashes every invocation可能已有人在做 @lechakrawarthy 于 11 天前认领。 未关闭bug good first issue help wanted idempotency
难度 2/5 1-3 小时 新手友好度 85/100
aws-powertools/powertools-lambda-python#8728 · 4 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
Bug: Redis layer fails the invocation instead of retrying when a record expires between SET NX and GET可能已有人在做 @coughlmao 于 11 天前认领。 未关闭bug good first issue help wanted idempotency
难度 2/5 1-3 小时 新手友好度 85/100
aws-powertools/powertools-lambda-python#8727 · 4 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
Bug: Redis orphan lock timeout ignores expires_after_seconds and is always 10 seconds可能已有人在做 @CJstate 于 11 天前认领。 未关闭bug good first issue help wanted idempotency
难度 2/5 1-3 小时 新手友好度 75/100
aws-powertools/powertools-lambda-python#8726 · 4 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
查看 aws-powertools/powertools-lambda-python 的全部 Issue
相似的 Issue
-
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
难度 2/5 1-3 小时 新手友好度 78/100
Huerte/algo-solutions-python#254 ·
维护者通常 1 天内回复
-
难度 1/5 1-3 小时 新手友好度 86/100
MichaelYcJo/SpecSeal#1543 ·
-
size/s
难度 1/5 1 小时以内 新手友好度 90/100
sipyourdrink-ltd/bernstein#7179 ·
维护者通常 1 天内回复
-
good first issue help wanted python up-for-grabs
难度 2/5 1-3 小时 新手友好度 65/100
andrewsiah/agentswarm-data-tasks#309 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 84/100
维护者通常 1 天内回复