Skip to content

GH#934: fix(ses): correct SES v2 API endpoint base path and identity route#936

Merged
superdav42 merged 2 commits intomainfrom
feature/auto-20260424-230755-gh934
Apr 25, 2026
Merged

GH#934: fix(ses): correct SES v2 API endpoint base path and identity route#936
superdav42 merged 2 commits intomainfrom
feature/auto-20260424-230755-gh934

Conversation

@superdav42
Copy link
Copy Markdown
Collaborator

@superdav42 superdav42 commented Apr 25, 2026

Summary

SES v2 API calls were hitting wrong URLs because the API_BASE constant lacked the required /email/ path segment, and identity endpoints used the non-existent /email-identities path instead of /identities.

Changes

  • API_BASE: https://email.{region}.amazonaws.com/v2/https://email.{region}.amazonaws.com/v2/email/
    • test_connection() now calls GET /v2/email/account (was /v2/account)
    • get_sending_statistics() now calls GET /v2/email/account/sending-statistics
    • intercept_wp_mail() / send_email() now call POST /v2/email/outbound-emails
  • Identity endpoints: email-identitiesidentities (4 call sites in class-amazon-ses-transactional-email.php)
    • verify_domain(): POST /v2/email/identities
    • get_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}
  • Tests: Updated 4 mock assertions in Amazon_SES_Transactional_Email_Test + added /v2/email/ path assertion to Amazon_SES_Integration_Test

Verification

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

  • Bug Fixes
    • Fixed Amazon SES integration to properly communicate with the SES v2 API by using the correct resource paths for email identity and domain management operations, ensuring reliable email delivery and domain verification.

…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
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 25, 2026

Warning

Rate limit exceeded

@superdav42 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 51 minutes and 18 seconds before requesting another review.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 28807cf8-f1d2-4cfc-adce-47d73f793d2b

📥 Commits

Reviewing files that changed from the base of the PR and between b9c4d86 and bb769d7.

📒 Files selected for processing (2)
  • inc/integrations/providers/amazon-ses/class-amazon-ses-transactional-email.php
  • tests/WP_Ultimo/Integrations/Providers/Amazon_SES/Amazon_SES_Transactional_Email_Test.php
📝 Walkthrough

Walkthrough

The Amazon SES integration API endpoints were corrected to match SES v2 specifications. The base URL now includes /v2/email/ path segment, and domain identity operations updated from email-identities to identities resource paths. Tests were updated to verify the corrected endpoints.

Changes

Cohort / File(s) Summary
API Configuration and Endpoints
inc/integrations/providers/amazon-ses/class-amazon-ses-integration.php, inc/integrations/providers/amazon-ses/class-amazon-ses-transactional-email.php
SES v2 base URL now appends /email/ to path, and domain identity operations changed from email-identities to identities endpoints. Documentation updated to reflect corrected resource paths.
Test Verification
tests/WP_Ultimo/Integrations/Providers/Amazon_SES/Amazon_SES_Integration_Test.php, tests/WP_Ultimo/Integrations/Providers/Amazon_SES/Amazon_SES_Transactional_Email_Test.php
Test assertions strengthened to verify /v2/email/ path inclusion and mock expectations updated to target corrected identities endpoint instead of email-identities.

Possibly Related PRs

Poem

🐰 A hop of delight, the paths now are right,
From /v2/ to /v2/email/ in the AWS night,
identities now replace those old email names,
SES v2 endpoints corrected—no more 404 games!


🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title clearly and concisely describes the main change: correcting the SES v2 API endpoint base path and identity route, which directly addresses the changeset across all modified files.
Linked Issues check ✅ Passed The PR fully addresses issue #934 requirements: correcting the API base URL to include /v2/email/, fixing account endpoint, sending endpoint, and identity endpoints from email-identities to identities, all with passing tests.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing SES v2 API endpoints as specified in issue #934; no unrelated modifications to request logic, error handling, or other functionality are present.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/auto-20260424-230755-gh934

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown

🔨 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!
Playground support for multisite is very limitied, hopefully it will get better in the future.

🚀 Launch in Playground

Login credentials: admin / password

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

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 | 🟠 Major

The endpoint account/sending-statistics is 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. GetSendStatistics is 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 ranges
  • get-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–286 mocks the incorrect endpoint and so passes; once the production call is fixed, that mock should also be updated.

Two reasonable paths forward:

  1. Switch to BatchGetMetricData for SEND/DELIVERY/BOUNCE/COMPLAINT metrics (richer, but requires a date range and different response shape).
  2. 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

📥 Commits

Reviewing files that changed from the base of the PR and between 3fd1267 and b9c4d86.

📒 Files selected for processing (4)
  • inc/integrations/providers/amazon-ses/class-amazon-ses-integration.php
  • inc/integrations/providers/amazon-ses/class-amazon-ses-transactional-email.php
  • tests/WP_Ultimo/Integrations/Providers/Amazon_SES/Amazon_SES_Integration_Test.php
  • tests/WP_Ultimo/Integrations/Providers/Amazon_SES/Amazon_SES_Transactional_Email_Test.php

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 25, 2026

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: /

Run DB Queries Memory Before Template Template WP Total LCP TTFB LCP - TTFB
0 40 (-1 / -3% ) 37.78 MB 840.50 ms (-29.00 ms / -3% ) 160.00 ms (-5.50 ms / -3% ) 1081.00 ms 2020.00 ms (-102.00 ms / -5% ) 1924.15 ms (-113.60 ms / -6% ) 88.00 ms
1 56 49.03 MB 950.00 ms 151.00 ms 1106.00 ms 2082.00 ms 1995.40 ms 81.40 ms (-2.05 ms / -3% )

…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
@github-actions
Copy link
Copy Markdown

🔨 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!
Playground support for multisite is very limitied, hopefully it will get better in the future.

🚀 Launch in Playground

Login credentials: admin / password

@superdav42 superdav42 merged commit 99b07ad into main Apr 25, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ultimate Multisite was testing SES by calling the wrong URL, so AWS returned 404 Not Found before IAM permissions really mattered.

1 participant