faker-ruby/faker · error · ArgumentError
Given argument is too large
Error message
Given argument is too large
What it means
Error "Given argument is too large" thrown in faker-ruby/faker.
Source
Thrown at lib/faker/internet.rb:78
# @param specifier [Integer, Range, String] When int value passed it returns the username longer than specifier. Max value can be 10^6
# @param separators [Array]
#
# @example
# Faker::Internet.username(specifier: 10) #=> "lulu.goodwin"
# Faker::Internet.username(specifier: 5..10) #=> "morris"
# Faker::Internet.username(specifier: 5..10) #=> "berryberry"
# Faker::Internet.username(specifier: 20, separators: ['_']) #=> "nikki_sawaynnikki_saway"
def username(specifier: nil, separators: %w[. _])
with_locale(:en) do
case specifier
when ::String
names = specifier.gsub("'", '').scan(/[[:word:]]+/)
shuffled_names = shuffle(names)
return shuffled_names.join(sample(separators)).downcase
when Integer
# If specifier is Integer and has large value, Argument error exception is raised to overcome memory full error
raise ArgumentError, 'Given argument is too large' if specifier > 10**6
tries = 0 # Don't try forever in case we get something like 1_000_000.
result = nil
loop do
result = username(specifier: nil, separators: separators)
tries += 1
break unless result.length < specifier && tries < 7
end
return result * (specifier / result.length + 1) if specifier.positive?
when Range
tries = 0
result = nil
loop do
result = username(specifier: specifier.min, separators: separators)
tries += 1
break unless !specifier.include?(result.length) && tries < 7
end
return result[0...specifier.max]View on GitHub (pinned to cca4184947)
When it happens
Trigger: Thrown at lib/faker/internet.rb:78 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of faker-ruby/faker@cca4184947 (2026-08-21).
Data as JSON: /api/errors/3110dcd539c28c17.
Report an issue: GitHub.