Skip to content

SES: Fix sent email counter double incrementing#7919

Merged
viren-nadkarni merged 2 commits intomasterfrom
ses-sent-email-counter
Mar 23, 2023
Merged

SES: Fix sent email counter double incrementing#7919
viren-nadkarni merged 2 commits intomasterfrom
ses-sent-email-counter

Conversation

@viren-nadkarni
Copy link
Member

Remove Moto operation being invoked twice which caused sent email counter to be double incremented.

Fixes #7902

@viren-nadkarni viren-nadkarni self-assigned this Mar 21, 2023
@viren-nadkarni viren-nadkarni temporarily deployed to localstack-ext-tests March 21, 2023 10:05 — with GitHub Actions Inactive
@viren-nadkarni viren-nadkarni requested a review from bentsku March 21, 2023 10:06
@coveralls
Copy link

coveralls commented Mar 21, 2023

Coverage Status

Coverage: 85.131% (+0.2%) from 84.943% when pulling cf8aba8 on ses-sent-email-counter into f141482 on master.

@github-actions
Copy link

github-actions bot commented Mar 21, 2023

LocalStack integration with Pro

       3 files  ±  0         3 suites  ±0   1h 31m 45s ⏱️ - 3m 56s
1 845 tests +16  1 455 ✔️ +14  390 💤 +  2  0 ±0 
2 581 runs  +28  1 820 ✔️ +12  761 💤 +16  0 ±0 

Results for commit cf8aba8. ± Comparison against base commit f141482.

♻️ This comment has been updated with latest results.

Copy link
Contributor

@bentsku bentsku left a comment

Choose a reason for hiding this comment

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

I have one question regarding maybe something out of scope of this PR.
If this is too out of scope, I guess we could simplify the test to not have Destinations recipients and only one header To:? Or the same example as in the issue, one Destinations and no headers.
And create an xfailed test for the wrong behaviour of moto.

)

new_counter = ses_client.get_send_quota()["SentLast24Hours"]
assert new_counter == counter + 2
Copy link
Contributor

Choose a reason for hiding this comment

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

question: I am confused, wasn't the issue report that the counter should be only +1? Or am I missing something?
After checking in moto, it seems moto is adding recipients from the raw headers to the sum. However, what if the recipient in Destinations and in the headers is the same? It seems they would be counted twice. (this previous part was before finding out the answer in the post under).

Also, after finding an old bug report in LocalStack and this SO post:
#6287
https://stackoverflow.com/questions/27446357/how-to-add-cc-and-bcc-in-amazon-ses-sendrawemail

It seems that if we have Destinations set then we shouldn't take into account the headers. So the count should be +1 here?

Copy link
Member Author

@viren-nadkarni viren-nadkarni Mar 23, 2023

Choose a reason for hiding this comment

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

Good catch! I confirmed this against prod AWS. This will need fixes both in LS and Moto and a out of scope of this issue. For now I've updated the test and added a fixme in the SES provider

@viren-nadkarni viren-nadkarni temporarily deployed to localstack-ext-tests March 23, 2023 07:43 — with GitHub Actions Inactive
Copy link
Contributor

@bentsku bentsku left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks for adding the note 👍

@viren-nadkarni viren-nadkarni merged commit 6ec5683 into master Mar 23, 2023
@viren-nadkarni viren-nadkarni deleted the ses-sent-email-counter branch March 23, 2023 13:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: Incorrect email count from SES:GetSendQuota after using SES:SendRawEmail

3 participants