Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion products/messaging/backend/providers/ses.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,23 @@
)

def create_email_domain(self, domain: str, team_id: int):
# NOTE: For sesv1 creation is done through verification
# NOTE: For sesv1, domain Identity creation is done through verification
self.verify_email_domain(domain, team_id)

# Create a tenant for the domain if not exists
try:
tenant_name = f"team-{team_id}"
self.client.create_tenant(TenantName=tenant_name, Tags=[{"Key": "team_id", "Value": str(team_id)}])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: AWS tenant names have specific constraints (3-64 characters, alphanumeric and hyphens). Consider validating the generated tenant name meets these requirements

Prompt To Fix With AI
This is a comment left during a code review.
Path: products/messaging/backend/providers/ses.py
Line: 29:31

Comment:
**style:** AWS tenant names have specific constraints (3-64 characters, alphanumeric and hyphens). Consider validating the generated tenant name meets these requirements

How can I resolve this? If you propose a fix, please make it concise.

except ClientError as e:
if e.response["Error"]["Code"] != "AlreadyExistsException":
raise

# Associate the new domain identity with the tenant
self.client.create_tenant_resource_association(
TenantName=tenant_name,
ResourceArn=f"arn:aws:ses:{settings.SES_REGION}:{settings.SES_ACCOUNT_ID}:identity/{domain}",

Check failure on line 39 in products/messaging/backend/providers/ses.py

View workflow job for this annotation

GitHub Actions / Python code quality checks

'Settings' object has no attribute 'SES_ACCOUNT_ID'
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: The tenant-resource association call lacks error handling, which could leave the system in an inconsistent state if tenant creation succeeds but association fails

Prompt To Fix With AI
This is a comment left during a code review.
Path: products/messaging/backend/providers/ses.py
Line: 37:40

Comment:
**logic:** The tenant-resource association call lacks error handling, which could leave the system in an inconsistent state if tenant creation succeeds but association fails

How can I resolve this? If you propose a fix, please make it concise.


def verify_email_domain(self, domain: str, team_id: int):
# Validate the domain contains valid characters for a domain name
DOMAIN_REGEX = r"(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$"
Expand Down
Loading