{"record":{"id":"14c958927aef3f6f","repo":"bchavez/Bogus","slug":"one-of-the-arguments-for-mm-name-is-out-of-suppo","errorCode":null,"errorMessage":"One of the arguments for {mm.Name} is out of supported range. Argument list: {string.Join(\",\", parameters)}","messagePattern":"One of the arguments for (.+?) is out of supported range\\. Argument list: (.+?)","errorType":"exception","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"Source/Bogus/Tokenizer.cs","lineNumber":148,"sourceCode":"         where mm.Method.GetParameters().Length >= arguments.Length\n         where mm.OptionalArgs.Length + arguments.Length >= mm.Method.GetParameters().Length\n         select mm;\n\n      var found = selection.FirstOrDefault();\n      return found ?? throw new ArgumentException($\"Cannot find a method '{methodName}' that could accept {arguments.Length} arguments\");\n   }\n\n   private static object[] ConvertStringArgumentsToObjects(string[] parameters, MustashMethod mm)\n   {\n      try\n      {\n         return mm.Method.GetParameters()\n                         .Zip(parameters, GetValueForParameter)\n                         .ToArray();\n      }\n      catch (OverflowException ex)\n      {\n         throw new ArgumentOutOfRangeException($\"One of the arguments for {mm.Name} is out of supported range. Argument list: {string.Join(\",\", parameters)}\", ex);\n      }\n      catch (Exception ex) when (ex is InvalidCastException or FormatException)\n      {\n         throw new ArgumentException($\"One of the arguments for {mm.Name} cannot be converted to target type. Argument list: {string.Join(\",\", parameters)}\", ex);\n      }\n      catch (Exception ex)\n      {\n         throw new ArgumentException($\"Cannot parse arguments for {mm.Name}. Argument list: {string.Join(\",\", parameters)}\", ex);\n      }\n   }\n\n   private static object GetValueForParameter(ParameterInfo parameterInfo, string parameterValue)\n   {\n      var type = Nullable.GetUnderlyingType(parameterInfo.ParameterType) ?? parameterInfo.ParameterType;\n\n      if( typeof(Enum).IsAssignableFrom(type)) return Enum.Parse(type, parameterValue);\n\n      if( typeof(TimeSpan) == type ) return TimeSpan.Parse(parameterValue);","sourceCodeStart":130,"sourceCodeEnd":166,"githubUrl":"https://github.com/bchavez/Bogus/blob/6ece18c5c22648ab4606e45a0aaf2f07fc5259e4/Source/Bogus/Tokenizer.cs#L130-L166","documentation":"Wrapping handler in Tokenizer.ConvertStringArgumentsToObjects (Tokenizer.cs:148). While turning template string args into typed values (GetValueForParameter uses Convert.ChangeType / Enum.Parse / TimeSpan.Parse), an OverflowException was raised: the value parsed syntactically but exceeded the target type's representable range. Bogus rethrows it as ArgumentOutOfRangeException, preserving the original as InnerException.","triggerScenarios":"A numeric argument whose magnitude exceeds the parameter type, e.g. {{random.number(99999999999)}} where Number's params are int (max 2,147,483,647), or a year/epoch value beyond a target numeric type's range, or an integral value outside an enum's underlying-type range.","commonSituations":"Hard-coding large IDs/timestamps/epochs in templates; forgetting that Randomizer.Number(min,max) takes int not long; locale/format differences producing unexpectedly large parsed numbers; passing a long-style value where an int param is expected.","solutions":["Clamp the offending argument to the target type's range (int: +/-2,147,483,647; long: +/-9.2e18).","If you need larger magnitudes, use a dataset method whose parameter accepts a wider type, if one exists.","Read the error's 'Argument list:' to find which positional argument overflowed, then fix that one value."],"exampleFix":"// before\nfaker.Parse(\"{{random.number(99999999999)}}\");\n// after\nfaker.Parse(\"{{random.number(1,1000000)}}\");","handlingStrategy":"validation","validationCode":"// For numeric arguments, verify they fit the target parameter type before parsing.\nstatic bool Fits(string value, Type targetType)\n{\n    var t = Nullable.GetUnderlyingType(targetType) ?? targetType;\n    try { Convert.ChangeType(value, t, CultureInfo.InvariantCulture); return true; }\n    catch (OverflowException) { return false; }\n    catch { return true; } // not a range problem; let the real converter handle it\n}","typeGuard":null,"tryCatchPattern":"try { var s = faker.Parse(tpl); }\ncatch (ArgumentOutOfRangeException ex) when (ex.Message.Contains(\"out of supported range\"))\n{\n    // Inspect ex.Message 'Argument list:' to find the overflowing positional arg.\n    throw new InvalidOperationException($\"Numeric arg out of range in template: {tpl}\", ex);\n}","preventionTips":["Keep numeric literals in templates within int32 range unless you know the param is wider.","Remember Randomizer.Number bounds are int, not long.","Avoid templating raw epoch milliseconds into int parameters."],"tags":["mustache-template","argument-range","overflow","tokenizer"],"backgroundTag":null,"analyzedSha":"6ece18c5c22648ab4606e45a0aaf2f07fc5259e4","analyzedAt":"2026-08-13T21:08:15.463Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}