replaceBrackets 'replace' of undefined: MailerSend in Make
The error means a MailerSend module in Make received an empty (undefined) value where it expected text, and its internal replaceBrackets function failed on it. Open the failed execution, find the mapped field that came through empty, and give it a fallback value or filter out the empty run.
Sohail Hussain8 min readShort answer
- The MailerSend module in Make tried to run a text replace on a field that arrived empty. Open the failed execution, read the module's Input, and find the mapped value that is blank.
- Fill it, give it a default with ifempty(), or add a filter so empty bundles never reach the module.
- If every field has a real value and the error remains, send Make support the execution ID and the module Input.
You are running a Make scenario with a MailerSend module and it stops with this:
Function 'replaceBrackets' finished with error! Cannot read property 'replace' of undefined
Nothing in the message says which field is the problem, which is why it feels so opaque. The good news is that it nearly always comes down to one mapped value that was empty on that run.
Why it happens
replaceBrackets is a function inside the module's own code, not a response from MailerSend. The second half of the message is a standard JavaScript failure: code called .replace() on a value that was undefined, and undefined has no such method.
That tells you a few things:
- There is no SMTP code or HTTP status to decode. The failure most likely happened while the module was preparing the request, so MailerSend probably never saw it.
- Because it is a code-level failure, the cause is almost always an input: a field you mapped that held no value on that execution.
- I can't see the module's source, so I can't say which field it runs
replaceBracketson. Treat the suspect list below as likely, not certain.
People on Make's community forum reported this error in late 2024. I can't confirm whether Make has changed the module since, as of November 2026.
Most likely causes
| Cause | Symptom | Fix |
|---|---|---|
| Optional upstream field left blank | Works for most records, fails on some | Default it with ifempty() |
| Mapped item missing from the previous module's output | Input shows an empty field | Re-map from the correct module |
| Template variable with a key but no value | Fails only for certain recipients | Fill or remove the variable |
| Stale saved module configuration | Fails even with full data, older scenario | Rebuild the module |
| Possible module bug | All fields populated, still fails | Bypass with HTTP module, contact Make |
Find the empty value
- Open your scenario and go to its execution History, then open the failed execution.
- Open the MailerSend module's bubble and read its Input. Look for any field that is blank, missing, or shows no value.
- Check the module before it. Open its Output and confirm the field you mapped actually exists in that bundle. A mapped item that is absent from the output resolves to empty.
- Compare a failing run with a successful one. The field that differs is your culprit.
The likeliest suspects are fields that hold text and may be scanned for placeholders: subject, text or HTML body, template variables or personalization values, and sender or recipient names. An optional form field or a CRM property left blank is the classic source.
Check the right bundle
If the scenario processes many bundles, the failing one may not be the first. Open the execution and step through each bundle's Input rather than judging by the first one.
Fix 1: give the field a fallback
If the value is sometimes missing and a default is acceptable, wrap the mapping in ifempty():
{{ifempty(3.customer_name; "there")}}
Replace 3.customer_name with the real mapped item, where 3 is the module number. Do the same for every variable or personalization value you pass in. If no sensible default exists, a single space can work, though some APIs reject blank required fields.
Fix 2: stop empty bundles before the module
If a missing value means the email should not go out at all:
- Click the connector line between the previous module and MailerSend and choose Set up a filter.
- Set the condition so the field Exists (or is not empty, depending on its type).
- Run the scenario again. Bundles lacking the value now stop at the filter instead of erroring.
For a record you want to review rather than drop, add an error handler route to the MailerSend module, for example a Break handler, so failed bundles are stored for retry.
Fix 3: check template variables
If you use a MailerSend template with variables, make sure each variable you map has a value for every recipient. A variable with a key but no value is a plausible way to get undefined into text processing. Remove optional variables you aren't filling, or default each one with ifempty().
Fix 4: rebuild the module or bypass it
Sometimes the saved module configuration is stale, particularly in older scenarios. Try these in order:
- Add a fresh MailerSend module, re-map the fields, and run it with Run this module only using the same input.
- Re-create the connection (API token) in the module's Connection field.
- If the error persists with all fields populated, skip the module and call the API yourself with Make's HTTP module (Make a request), posting to
https://api.mailersend.com/v1/emailwith anAuthorization: Bearerheader and a JSON body.
The HTTP route also lets you log the API response. The output shows MailerSend's real status code and error body, which the native module can't show when it fails first. A 422 there, for instance, names the invalid field.
Keep your token private
When you copy module input or HTTP requests into a support ticket, remove the API token and any recipient personal data first.
Checklist before you run it again
- Every mapped field in the module's Input has a real value on the failing bundle.
- Each optional field has an
ifempty()default or a filter in front of it. - Every template variable has a value for every recipient.
- The mapped items point at modules that actually appear earlier in the scenario.
- An error handler is attached so one bad bundle doesn't stall the rest.
If nothing works
If every mapped field has a real value and the error still appears, it may be a module bug. Contact Make support, and mention whether the same input works through the HTTP module; that tells them the fault is in the module, not your data. Include:
- the execution ID from History and the timestamp
- the module name and version shown in the scenario
- a copy of the module's Input from the failing run, with secrets removed
- the exact error text
- what you already tried
Subject: MailerSend module error "replaceBrackets ... of undefined"
Hello,
My scenario {scenario name} fails in the MailerSend module with:
Function 'replaceBrackets' finished with error! Cannot read property 'replace' of undefined
Execution ID: {execution id}
Time (UTC): {timestamp}
Module version: {version}
All mapped fields have values in the Input (attached). I rebuilt the module and
re-created the connection. The same input works / does not work through the HTTP
module calling https://api.mailersend.com/v1/email.
Could you check whether this is a module issue?
Thanks,
{your name}
Prevent it
- Default every dynamic value that can be blank with
ifempty(). - Put a filter in front of any module whose required fields come from optional upstream data.
- Test with a deliberately incomplete record, not just your clean sample.
- Keep an error handler on email-sending modules.
If you are weighing whether transactional email belongs in an automation tool at all, our notes on transactional vs marketing emails and email APIs and webhooks cover the trade-offs.
Common questions
Is this a MailerSend problem or a Make problem?
Most likely neither service is down. The error comes from the module's code processing an empty input, so the fix is usually in your mapping. If all inputs are populated, it points to the module, and Make support is the right contact.
Will the email still send if I use a single space as a default?
It can, but some APIs reject blank required fields, so a real default such as a name or "there" is safer.
Why does it work for some records and fail for others?
Because the empty field only occurs on some bundles. Compare a failing execution with a successful one in History to see which value differs.
Does the HTTP module replace the MailerSend module fully?
It can send the same request, but you build the JSON body and headers yourself. In exchange you see MailerSend's real response.
Explore: Email Marketing Strategy
Related Articles
414 Request-URI Too Large in n8n's Amazon SES node: fix
The error 414 Request-URI Too Large in n8n's AWS SES node means a server in the path refused a request whose URL was too long, which a long HTML body can cause when it travels in the URL. Send through the SES v2 API with an HTTP Request node, or use SES SMTP.
Access denied, bad outbound sender: Outlook cold email fix
"Access denied, bad outbound sender" (550 5.1.8) means Microsoft 365 has put your mailbox on its restricted users list for spam-like sending. An admin must unblock it under Restricted entities in the Microsoft Defender portal. Then clean your list, lower your volume and resume gradually.
Acoustic Campaign "Application error" on login: bookmark fix
Acoustic Campaign shows "application error" at login when you open it from a bookmark saved while you were logged in, because the bookmark carries the old session. Log out, type your pod URL (campaign-us-[X].goacoustic.com) into the address bar, log in, then save a fresh bookmark.
ActiveCampaign 502 Bad Gateway and Tags Failed to Load: Fixes
"Bad gateway Error code 502" in ActiveCampaign means Cloudflare, the proxy in front of the app, got no valid response from ActiveCampaign's servers. That is usually their side. Check the status page, retry in a clean browser session, clear cookies, then send support the Ray ID if it persists.
Ready to supercharge your email marketing?
Start sending smarter emails with AI-powered campaigns. No credit card required.
Get Started Free