bchavez/Bogus · error · ArgumentException
The method call '{methodCall}' is missing a terminating ')'
Error message
The method call '{methodCall}' is missing a terminating ')' character. What it means
Thrown by Tokenizer.GetArgumentsString (Tokenizer.cs:176). Once ParseMustashText sees an opening '(' it enters argument mode and asks GetArgumentsString for the text up to the first ')'. If no ')' exists in the call text it throws ArgumentException. The tokenizer found an argument list opener but the call never closes.
Source
Thrown at Source/Bogus/Tokenizer.cs:176
}
private static object GetValueForParameter(ParameterInfo parameterInfo, string parameterValue)
{
var type = Nullable.GetUnderlyingType(parameterInfo.ParameterType) ?? parameterInfo.ParameterType;
if( typeof(Enum).IsAssignableFrom(type)) return Enum.Parse(type, parameterValue);
if( typeof(TimeSpan) == type ) return TimeSpan.Parse(parameterValue);
return Convert.ChangeType(parameterValue, type);
}
private static string GetArgumentsString(string methodCall, int parametersStart)
{
var parametersEnd = methodCall.IndexOf(')');
if( parametersEnd == -1 )
{
throw new ArgumentException($"The method call '{methodCall}' is missing a terminating ')' character.");
}
return methodCall.Substring(parametersStart + 1, parametersEnd - parametersStart - 1);
}
}
[AttributeUsage(AttributeTargets.Property)]
internal class RegisterMustasheMethodsAttribute : Attribute;View on GitHub (pinned to 6ece18c5c2)
Solutions
- Ensure every {{category.method(...)}} has a ')' before the closing '}}'.
- Run a paren-balance/shape check on the template before parsing.
- If you don't need arguments, omit the parentheses entirely: {{random.number}} selects the 0-arg overload and never enters argument mode.
Example fix
// before
faker.Parse("{{random.number(5}}");
// after
faker.Parse("{{random.number(5,100)}}"); Defensive patterns
Strategy: validation
Validate before calling
// Verify every token that opens '(' also closes ')' before the '}}'.
static bool TemplatesWellFormed(string tpl)
{
foreach (Match m in Regex.Matches(tpl, @"\{\{(.*?)\}\}"))
{
var body = m.Groups[1].Value;
if (body.Contains('(') && !body.Contains(')')) return false;
}
return true;
} Try / catch
try { var s = faker.Parse(tpl); }
catch (ArgumentException ex) when (ex.Message.Contains("missing a terminating ')'"))
{
throw new InvalidOperationException($"Malformed handlebar (no closing paren) in template: {tpl}", ex);
} Prevention
- For no-argument calls, drop the parentheses: {{random.number}} is valid and avoids this path entirely.
- Add a unit test that parses every template constant at startup to catch truncation early.
- Watch for config/templating layers that strip trailing punctuation and silently eat ')'.
When it happens
Trigger: A token with '(' but no matching ')': {{random.number(5}} (forgot the paren), {{name.lastname(}}, or a copy-paste that dropped the closing characters. Because the parser locates the outer '}}' first with IndexOf, any stray content can consume the intended ')'.
Common situations: Hand-authoring templates; a templating/config layer that strips trailing punctuation and silently removes ')'; nested/malformed handlebars where '}}' appears before the intended ')'.
Related errors
- Can't parse {methodName} because the dataset was not provide
- Cannot find a method '{methodName}' that could accept {argum
- One of the arguments for {mm.Name} is out of supported range
- One of the arguments for {mm.Name} cannot be converted to ta
- Cannot parse arguments for {mm.Name}. Argument list: {string
AI-assisted analysis of bchavez/Bogus@6ece18c5c2 (2026-08-13).
Data as JSON: /api/errors/d927149bbb30aa9b.
Report an issue: GitHub.