GH#934: fix(ses): correct SES v2 API endpoint base path and identity route#936
GH#934: fix(ses): correct SES v2 API endpoint base path and identity route#936superdav42 merged 2 commits intomainfrom
Conversation
…route - Change API_BASE from /v2/ to /v2/email/ so all SES v2 requests hit the correct resource prefix (e.g. /v2/email/account, not /v2/account) - Rename email-identities endpoint to identities throughout the transactional email module, matching the actual SES v2 route /v2/email/identities (not /v2/email-identities) - Update all test assertions to reflect the corrected endpoint strings - Add /v2/email/ path assertion to test_get_api_base_includes_region Fixes #934
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 51 minutes and 18 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe Amazon SES integration API endpoints were corrected to match SES v2 specifications. The base URL now includes Changes
Possibly Related PRs
Poem
🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🔨 Build Complete - Ready for Testing!📦 Download Build Artifact (Recommended)Download the zip build, upload to WordPress and test:
🌐 Test in WordPress Playground (Very Experimental)Click the link below to instantly test this PR in your browser - no installation needed! Login credentials: |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
inc/integrations/providers/amazon-ses/class-amazon-ses-transactional-email.php (1)
431-461:⚠️ Potential issue | 🟠 MajorThe endpoint
account/sending-statisticsis not valid in SES v2 — this call will return 404 in production after the PR.Although this line wasn't touched by the PR, it's directly in scope for the stated goal of resolving 404 responses. With the corrected base URL, the request becomes
GET https://email.{region}.amazonaws.com/v2/email/account/sending-statistics, which does not exist in the SES v2 (2019-09-27) API.GetSendStatisticsis an SES v1-only operation; the SES v2 operation list does not include it or a sending-statistics endpoint.SES v2 exposes sending metrics instead via:
GET /v2/email/account— returns account SendQuota (max and sent in last 24 hours)BatchGetMetricData— returns detailed VDM metrics (SEND, DELIVERY, BOUNCES, COMPLAINTS) with date rangesget-domain-statistics-report— domain-specific volume statistics- CloudWatch and the SES console for historical data
The corresponding test in
Amazon_SES_Transactional_Email_Test.php:264–286mocks the incorrect endpoint and so passes; once the production call is fixed, that mock should also be updated.Two reasonable paths forward:
- Switch to
BatchGetMetricDatafor SEND/DELIVERY/BOUNCE/COMPLAINT metrics (richer, but requires a date range and different response shape).- Drop SES-side stats entirely and document that statistics must be sourced from CloudWatch or the SES console.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@inc/integrations/providers/amazon-ses/class-amazon-ses-transactional-email.php` around lines 431 - 461, get_sending_statistics currently calls the non-existent SES v2 endpoint 'account/sending-statistics' which will 404; replace that call inside get_sending_statistics with a supported approach: either implement a BatchGetMetricData call (use SES v2 BatchGetMetricData to request SEND/DELIVERY/BOUNCES/COMPLAINTS over a date range and adapt parsing logic to the BatchGetMetricData response shape) or call GET /v2/email/account to return SendQuota-only values or else remove the SES-side stats and return a clear message directing consumers to CloudWatch/SES console; also update the Amazon_SES_Transactional_Email_Test.php mocks (lines around the test) to reflect the chosen approach (mock BatchGetMetricData or /v2/email/account or adjust expectations) so tests no longer assume the old sending-statistics endpoint.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In
`@inc/integrations/providers/amazon-ses/class-amazon-ses-transactional-email.php`:
- Around line 431-461: get_sending_statistics currently calls the non-existent
SES v2 endpoint 'account/sending-statistics' which will 404; replace that call
inside get_sending_statistics with a supported approach: either implement a
BatchGetMetricData call (use SES v2 BatchGetMetricData to request
SEND/DELIVERY/BOUNCES/COMPLAINTS over a date range and adapt parsing logic to
the BatchGetMetricData response shape) or call GET /v2/email/account to return
SendQuota-only values or else remove the SES-side stats and return a clear
message directing consumers to CloudWatch/SES console; also update the
Amazon_SES_Transactional_Email_Test.php mocks (lines around the test) to reflect
the chosen approach (mock BatchGetMetricData or /v2/email/account or adjust
expectations) so tests no longer assume the old sending-statistics endpoint.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 959e2910-f461-4ed5-8c82-b6df8110594d
📒 Files selected for processing (4)
inc/integrations/providers/amazon-ses/class-amazon-ses-integration.phpinc/integrations/providers/amazon-ses/class-amazon-ses-transactional-email.phptests/WP_Ultimo/Integrations/Providers/Amazon_SES/Amazon_SES_Integration_Test.phptests/WP_Ultimo/Integrations/Providers/Amazon_SES/Amazon_SES_Transactional_Email_Test.php
|
Performance Test Results Performance test results for e30dfb1 are in 🛎️! Note: the numbers in parentheses show the difference to the previous (baseline) test run. Differences below 2% or 0.5 in absolute values are not shown. URL:
|
…t endpoint SES v2 has no /v2/email/account/sending-statistics resource (that was a v1 endpoint). After the API_BASE fix, the call would hit the wrong URL and return 404. Switch get_sending_statistics() to GET /v2/email/account which exposes SendQuota.SentLast24Hours — the best available approximation without implementing BatchGetMetricData. Bounce/complaint counts are not available from this endpoint and return 0 with a comment directing consumers to CloudWatch for detailed metrics. Update the corresponding test mock and assertions to match the new shape. Ref #934
🔨 Build Complete - Ready for Testing!📦 Download Build Artifact (Recommended)Download the zip build, upload to WordPress and test:
🌐 Test in WordPress Playground (Very Experimental)Click the link below to instantly test this PR in your browser - no installation needed! Login credentials: |
Summary
SES v2 API calls were hitting wrong URLs because the
API_BASEconstant lacked the required/email/path segment, and identity endpoints used the non-existent/email-identitiespath instead of/identities.Changes
API_BASE:https://email.{region}.amazonaws.com/v2/→https://email.{region}.amazonaws.com/v2/email/test_connection()now callsGET /v2/email/account(was/v2/account)get_sending_statistics()now callsGET /v2/email/account/sending-statisticsintercept_wp_mail()/send_email()now callPOST /v2/email/outbound-emailsemail-identities→identities(4 call sites inclass-amazon-ses-transactional-email.php)verify_domain():POST /v2/email/identitiesget_domain_verification_status():GET /v2/email/identities/{domain}get_domain_dns_records():GET /v2/email/identities/{domain}on_domain_removed():DELETE /v2/email/identities/{domain}Amazon_SES_Transactional_Email_Test+ added/v2/email/path assertion toAmazon_SES_Integration_TestVerification
All existing tests pass against corrected endpoint strings. The bug caused every SES API call to return 404, making IAM permissions irrelevant since the URL was wrong before authorization was even evaluated.
Resolves #934
aidevops.sh v3.11.0 plugin for OpenCode v1.3.17 with claude-sonnet-4-6 spent 6m and 17,168 tokens on this as a headless worker.
Summary by CodeRabbit