Skip to content

mailgun: enable mangling and syncing with subdomains - #2724

Open
ubiratansoares wants to merge 1 commit into
mainfrom
u/mailgun-legacy-email-routes
Open

mailgun: enable mangling and syncing with subdomains#2724
ubiratansoares wants to merge 1 commit into
mainfrom
u/mailgun-legacy-email-routes

Conversation

@ubiratansoares

@ubiratansoares ubiratansoares commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

AI disclosure

I used Claude Code to get clarifications about these changes and deep search in the wild info on Mailgun's API rate limits.


Towards rust-lang/infra-team#297

We tweak the mangling logic to handle a special subdomain we'll introduce to enable the migration (of lists provisioned by team) from Mailgun to Google Groups.

sync does not support dry-runs for Mailgun in CI, so I had to test these changes manually.

echo "Preparing team static api"
cargo run --quiet static-api build
echo

echo "Dry-run changes against Mailgun"

MAILGUN_API_TOKEN=$(op read <path/to/secret>) \
EMAIL_PRIVATE_KEY=$(op read <path/to/secret>) \
  cargo run --quiet -- sync dry-run --services mailgun --src team-api
echo

A part of the output looks like this, I won't share it full since it'd disclose encrypted emails:

# .
# .
# previous output
#
[INFO  rust_team::sync::mailgun::api] deleting route with ID 5c5b479fa4764a000139448d
[INFO  rust_team::sync::mailgun::api] deleting route with ID 6321fe4584c515511ba78994
[INFO  rust_team::sync::mailgun::api] deleting route with ID 6321fe4565c9ab17d6be343e
[INFO  rust_team::sync::mailgun] creating list ^leah(?:\+.+)?@(?:legacy-lists\.)?rustconf\.com$
[INFO  rust_team::sync::mailgun] creating list ^infra-team(?:\+.+)?@(?:legacy-lists\.)?rust-lang\.org$
[INFO  rust_team::sync::mailgun] creating list ^community(?:\+.+)?@(?:legacy-lists\.)?rust-lang\.org$
[INFO  rust_team::sync::mailgun] creating list ^project-vision-doc-2025(?:\+.+)?@(?:legacy-lists\.)?rust-lang\.org$
#
# more output
# .
# .

This approach will delete and (re)create all 96 lists we currently have, rather than updating them in-place. This should be fine from the rate-limiting perspective for a single deploy (no official numbers, but 300 rpm mentioned on issues like this).

After lots of pain, I think this path worths compared with trying to update existing rules in-place and keeping guardrail checks to ensure consistency between the current and the new state (that was my first attempt).

Happy to get input in case I missed something.

@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown
Dry-run check results

[WARN  rust_team::sync] sync-team is running in dry mode, no changes will be applied.
[INFO  rust_team::sync] synchronizing crates-io
[INFO  rust_team::sync] synchronizing github
[INFO  rust_team::sync] 💻 Repo Diffs:
    📝 Editing repo 'rust-lang/rustup':
      Environments:
        ❌ Delete: copilot

@ubiratansoares
ubiratansoares force-pushed the u/mailgun-legacy-email-routes branch 2 times, most recently from e9fbf20 to 24694d0 Compare September 3, 2026 17:20
@ubiratansoares
ubiratansoares marked this pull request as ready for review September 3, 2026 18:33
Comment thread src/sync/mailgun/mod.rs Outdated
"list+bot@example.com",
"list+bot@legacy-lists.example.com",
] {
let re = regex::Regex::new(&mangle_address("list@example.com").unwrap());

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

let's move this above the for loop so we construct the regex once

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done!

@ubiratansoares
ubiratansoares force-pushed the u/mailgun-legacy-email-routes branch from 24694d0 to 43147e3 Compare September 4, 2026 10:55
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.

2 participants