Users are reporting an issue with Mailgun’s secret API key being rejected in Discourse due to a format validation error. The error occurs when entering a Mailgun API key, which typically starts with “key-” followed by 32 characters, but the regex validation in Discourse only accepts hexadecimal characters. Several users confirm they are using valid API keys, not SMTP passwords, and note that newer Mailgun keys include dashes, which may not match the current regex. Some users suggest the regex should be less restrictive, as invalid keys would still result in errors during use. A workaround is to generate a new API key with a hex-only format. pfaffman and lunikon discuss the issue, and oxxi notes the problem was resolved after updating the key. Uninen and mshappe confirm the issue persists across multiple versions.
I tried to set up Mailgun bounce handling today and therefore wanted to configure the secret Mailgun API key. But I can’t save the key and only get this error message:
Value doesn’t match the required format.
Have they changed their format maybe? My key is “key-” followed by 32 lower-case alpha-numeric characters.
Strange. I just opened a ticket on Mailgun asking if the API key format has changed.
Edit: And I heard back from them. It’s still the same. @lunikon, my best guess is that you’re using an SMTP password rather than an API key. You can look at my install FAQ for how to find the API key.
I am definitely using an API key, from the exact location described in your install FAQ. I guess I’ll have to contact Mailgun myself and figure out what went wrong there. Maybe there was a bug on their side when my set of keys was generated.
I’m having the same problem with v2.0.0.beta3. My Mailgun API key also has dashes in it, I assume the regex just doesn’t match. (And yes, I’m definitely using the correct secret key, not a password.)
So apparently this problem does exist for several people over a longer time-span. Wouldn’t it be easier to just make the regex in Discourse less restrictive? The worst that could happen is that someone enters a wrong key, resulting in an error message somewhere. But that could already happen today (with an expired key for example).
I had this problem.
I think older API keys are 32 alpha-numeric, and newer ones are 32 hex characters, and the regex only allows hex. I don’t use the API anywhere else, so I just re-generated my API key so I had a new hex-only one.
My current mailgun secret API key gives the error mailgun_api_key: Value doesn't match the required format. I’m on v2.1.0.beta3 +64. Anything I can do to make it accept my API key?