{"record":{"id":"2252044f0e2886be","repo":"faker-ruby/faker","slug":"size-should-be-specified-in-format-300x300-225204","errorCode":null,"errorMessage":"Size should be specified in format 300x300","messagePattern":"Size should be specified in format 300x300","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/faker/default/placeholdit.rb","lineNumber":33,"sourceCode":"      # @param text [String] Specifies a custom text to be used.\n      # @return [String]\n      #\n      # @example\n      #     # Keyword arguments: size, format, background_color, text_color, text\n      #   Faker::Placeholdit.image #=> \"https://via.placeholder.com/300x300.png\"\n      #   Faker::Placeholdit.image(size: '50x50') #=> \"https://via.placeholder.com/50x50.png\"\n      #   Faker::Placeholdit.image(size: '50x50', format: 'jpg') #=> \"https://via.placeholder.com/50x50.jpg\"\n      #   Faker::Placeholdit.image(size: '50x50', format: 'gif', background_color: 'ffffff') #=> \"https://via.placeholder.com/50x50.gif/ffffff\"\n      #   Faker::Placeholdit.image(size: '50x50', format: 'jpeg', background_color: :random) #=> \"https://via.placeholder.com/50x50.jpeg/39eba7\"\n      #   Faker::Placeholdit.image(size: '50x50', format: 'jpeg', background_color: 'ffffff', text_color: '000') #=> \"https://via.placeholder.com/50x50.jpeg/ffffff/000\"\n      #   Faker::Placeholdit.image(size: '50x50', format: 'jpg', background_color: 'ffffff', text_color: '000', text: 'Some Custom Text') #=> \"https://via.placeholder.com/50x50.jpg/ffffff/000?text=Some Custom Text\"\n      #\n      # @faker.version 1.6.0\n      def image(size: '300x300', format: 'png', background_color: nil, text_color: nil, text: nil)\n        background_color = generate_color if background_color == :random\n        text_color = generate_color if text_color == :random\n\n        raise ArgumentError, 'Size should be specified in format 300x300' unless size =~ /\\A[0-9]+x[0-9]+\\z$/\n        raise ArgumentError, \"Supported formats are #{SUPPORTED_FORMATS.join(', ')}\" unless SUPPORTED_FORMATS.include?(format)\n        raise ArgumentError, \"background_color must be a hex value without '#'\" unless background_color.nil? || background_color =~ /((?:^\\h{3}$)|(?:^\\h{6}$)){1}(?!.*\\H)/\n        raise ArgumentError, \"text_color must be a hex value without '#'\" unless text_color.nil? || text_color =~ /((?:^\\h{3}$)|(?:^\\h{6}$)){1}(?!.*\\H)/\n\n        image_url = \"https://via.placeholder.com/#{size}.#{format}\"\n        image_url += \"/#{background_color}\" if background_color\n        image_url += \"/#{text_color}\" if text_color\n        image_url += \"?text=#{text}\" if text\n        image_url\n      end\n\n      private\n\n      def generate_color\n        format('%06x', rand * 0xffffff)\n      end\n    end\n  end","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/faker-ruby/faker/blob/cca4184947e09fdd02afb8b89d25a9c8ebc7274e/lib/faker/default/placeholdit.rb#L15-L51","documentation":"Raised by Faker::Placeholdit.image when the size string does not match /\\A[0-9]+x[0-9]+\\z/ (the anchor `$` after `\\z` is redundant). The via.placeholder.com URL embeds size directly, so anything but digits-'x'-digits — '50', '50X50', '50 x 50', '50.5x50', nil — is rejected.","triggerScenarios":"Faker::Placeholdit.image(size: '100') or size: \"#{w}*#{h}\", size: \"#{w}x\" (nil height) raises 'Size should be specified in format 300x300'.","commonSituations":"Building size from ERB/view helpers where a dimension is nil or blank; user-provided dimensions from a query param; capital-X or Unicode multiplication-sign typos.","solutions":["Pass size as 'WIDTHxHEIGHT' with ASCII 'x', e.g. size: '50x50' (default '300x300').","Interpolate with to_i: size: \"#{width.to_i}x#{height.to_i}\".","Pre-validate with size =~ /\\A[0-9]+x[0-9]+\\z/ before calling."],"exampleFix":"# before\nFaker::Placeholdit.image(size: \"#{params[:w]}x#{params[:h]}\") # blank params -> 'x'\n\n# after\nFaker::Placeholdit.image(size: \"#{params[:w].to_i}x#{params[:h].to_i}\")","handlingStrategy":"validation","validationCode":"size = \"#{width.to_i}x#{height.to_i}\"\nsize = '300x300' unless size.match?(/\\A[0-9]+x[0-9]+\\z/)\nFaker::Placeholdit.image(size: size)","typeGuard":"def valid_placeholdit_size?(size)\n  size.is_a?(String) && size.match?(/\\A[0-9]+x[0-9]+\\z/)\nend","tryCatchPattern":"begin\n  Faker::Placeholdit.image(size: size)\nrescue ArgumentError\n  Faker::Placeholdit.image # default 300x300\nend","preventionTips":["Build size strings from integers only: \"#{w.to_i}x#{h.to_i}\".","Reject user-supplied sizes at the boundary with the same digits-x-digits regex.","View helpers should never interpolate possibly-nil dimensions."],"tags":["faker","argument-error","format-validation","image-url","placeholdit"],"backgroundTag":"invalid-format-argument","analyzedSha":"cca4184947e09fdd02afb8b89d25a9c8ebc7274e","analyzedAt":"2026-08-21T16:25:39.145Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}