Repository navigation
Closed
Copy link
Labels
good first issueGood for newcomersGood for newcomersparserParser (Pydantic) utilityParser (Pydantic) utilitytech-debtTechnical Debt tasksTechnical Debt tasks
Description
Description
Enhance the SNS parser models with field descriptions and examples using Pydantic's Field() functionality. This improvement will provide better documentation and metadata for SNS event parsing, following the pattern established in PR #7100.
Motivation
Currently, the SNS models lack detailed field documentation, making it harder for developers to:
- Understand field purposes without referencing external AWS documentation
- Generate rich API documentation with tools like Swagger/OpenAPI
- Create realistic test data using model factories
- Get helpful IntelliSense in IDEs
Proposed Changes
Add description and examples parameters to all fields in the following models using Field():
Files to modify:
aws_lambda_powertools/utilities/parser/models/sns.py
Reference events:
Check the sample events in tests/events/ for realistic field values:
snsEvent.jsonsnsEventBatch.json
Implementation Requirements
- ✅ Add detailed
descriptionfor each field explaining its purpose and usage - ✅ Include practical
examplesshowing realistic AWS SNS values - ✅ Base descriptions on official AWS SNS documentation
- ✅ Maintain all existing functionality, types, and validation logic
- ✅ Follow the same pattern established in EventBridge, Kinesis, and ALB models
Example Implementation
# Before
class SnsNotificationModel(BaseModel):
message_id: str
topic_arn: str
subject: str
message: str
timestamp: datetime
# After
class SnsNotificationModel(BaseModel):
message_id: str = Field(
description="A Universally Unique Identifier, unique for each message published.",
examples=[
"95df01b4-ee98-5cb9-9903-4c221d41eb5e",
"da41e39f-ea4d-435a-b922-c6aae3915ebe"
]
)
topic_arn: str = Field(
description="The Amazon Resource Name (ARN) for the topic that this message was published to.",
examples=[
"arn:aws:sns:us-east-1:123456789012:my-topic",
"arn:aws:sns:eu-west-1:123456789012:notification-topic"
]
)
subject: str = Field(
description="The subject parameter provided when the notification was published to the topic.",
examples=[
"Test notification",
"Alert: System maintenance scheduled"
]
)
message: str = Field(
description="The message value specified when the notification was published to the topic.",
examples=[
"Hello from SNS!",
'{"alert": "CPU usage above 80%", "instance": "i-1234567890abcdef0"}'
]
)
timestamp: datetime = Field(
description="The time (GMT) when the notification was published.",
examples=[
"2023-01-15T10:30:00.000Z",
"2023-12-25T18:45:30.123Z"
]
)Benefits
For Developers
- Better IntelliSense with field descriptions and example values
- Self-documenting code without needing external AWS documentation
- Faster development with immediate reference for acceptable values
For Documentation Tools
- Rich Swagger/OpenAPI docs via .model_json_schema()
- Automated documentation generation with comprehensive metadata
- Interactive documentation with practical examples
Getting Started
This is a great first issue for newcomers to Powertools for AWS! The task is straightforward and helps you get familiar with our codebase structure.
Need help?
We're here to support you! Feel free to:
- Ask questions in the comments
- Request guidance on implementation approach
Acknowledgment
- This request meets Powertools for AWS Lambda (Python) Tenets
- Should this be considered in other Powertools for AWS Lambda languages? i.e. Java, TypeScript, and .NET
Metadata
Metadata
Assignees
Labels
good first issueGood for newcomersGood for newcomersparserParser (Pydantic) utilityParser (Pydantic) utilitytech-debtTechnical Debt tasksTechnical Debt tasks
Type
Projects
- StatusShow more project fieldsComing soon
Activity
dcabib commentedon Aug 29, 2025
Hey @leandrodamascena! 👋 I'm excited to tackle this SNS models enhancement! After diving deep into your codebase and studying the pattern from PR #7100, here's my comprehensive plan to bring the SNS parser models up to the same high-quality documentation standard as your ALB models.
🔍 Current State Analysis
I've analyzed the current SNS models in
aws_lambda_powertools/utilities/parser/models/sns.pyand identified 4 main classes that need enhancement:SnsMsgAttributeModel- User-defined message attributes structureSnsNotificationModel- Core SNS notification (the most complex with validation logic)SnsRecordModel- Individual SNS record wrapperSnsModel- Root SNS event modelThe current implementation lacks the rich documentation that your ALB models now have, making it harder for developers to understand the intricacies of SNS events and their optional fields.
🎯 Implementation Strategy
Following the exact same pattern established in PR #7100, I'll add
Field()descriptions and examples to all fields. I've studied your ALB implementation and will maintain identical quality and consistency.Phase 1: SnsMsgAttributeModel Enhancement
Phase 2: SnsNotificationModel Enhancement
Phase 3: SnsRecordModel Enhancement
Phase 4: SnsModel Enhancement
📚 Data Sources & Validation
I've extracted realistic examples from:
tests/events/snsEvent.json- Your existing test dataAll examples are production-ready and reflect actual AWS SNS event structures, including the nuances of FIFO topics and SQS delivery protocol differences.
🎯 Benefits This Will Deliver
For Developers:
For Documentation Tools:
model_json_schema()For the Powertools Ecosystem:
✅ Quality Assurance
check_sqs_protocolvalidator logic maintained🤔 Questions & Considerations
check_sqs_protocolvalidator is really clever - should I add a description comment about this SQS vs HTTP delivery difference?Messagefield that can be a string or BaseModel, should I include both types in examples?💡 Special SNS Considerations
I noticed some interesting SNS-specific nuances that make this model particularly valuable to document well:
This enhancement will really help developers navigate these SNS complexities!
Ready to make the SNS models as polished and professional as the rest of your utilities! 🚀
leandrodamascena commentedon Aug 30, 2025
Hi @dcabib, thanks for offering support to work on this, please go ahead.
Make sure you don't change any type annotations or tests, okay?
I'm assigning this issue to you.
refactor(parser): Improve SNS models with examples and descriptions
powertools-for-aws-oss-automation commentedon Sep 1, 2025
Warning
This issue is now closed. Please be mindful that future comments are hard for our team to see.
If you need more assistance, please either reopen the issue, or open a new issue referencing this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.
refactor(parser): Improve SNS models with examples and descriptions (a…