{"record":{"id":"ffa1bd9dc48c5813","repo":"faker-ruby/faker","slug":"supported-formats-are-supported-formats-join-ffa1bd","errorCode":null,"errorMessage":"Supported formats are #{SUPPORTED_FORMATS.join(', ')}","messagePattern":"Supported formats are #(.+?)","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/faker/default/placeholdit.rb","lineNumber":34,"sourceCode":"      # @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\nend","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/faker-ruby/faker/blob/cca4184947e09fdd02afb8b89d25a9c8ebc7274e/lib/faker/default/placeholdit.rb#L16-L52","documentation":"Raised by Faker::Placeholdit.image when format is not in SUPPORTED_FORMATS: 'png', 'jpg', 'gif', 'jpeg'. The whitelist is an exact string match, so 'PNG', :png, 'webp', 'svg', or 'jpg ' all fail and the message enumerates the four allowed values.","triggerScenarios":"Faker::Placeholdit.image(format: 'webp'), format: 'PNG', or format: :png raises 'Supported formats are png, jpg, gif, jpeg'; format: 'png' (default) works.","commonSituations":"Forwarding a user-chosen or config-driven image format into the generator; assuming symbols are accepted like elsewhere in Faker; copy-pasting from placeholder services that support more formats (via.placeholder.com supports more than this gem whitelists).","solutions":["Use one of the exact lowercase strings: 'png', 'jpg', 'gif', 'jpeg'.","Downcase and whitelist user input first: format = %w[png jpg gif jpeg].include?(f) ? f : 'png'.","If you need another format, build the URL manually: \"https://via.placeholder.com/50x50.#{format}\"."],"exampleFix":"# before\nFaker::Placeholdit.image(format: requested_format) # 'webp' -> ArgumentError\n\n# after\nFaker::Placeholdit.image(format: 'png')\n# or bypass: \"https://via.placeholder.com/300x300.#{requested_format}\"","handlingStrategy":"type-guard","validationCode":"format = format.to_s.downcase\nformat = 'png' unless Faker::Placeholdit::SUPPORTED_FORMATS.include?(format)\nFaker::Placeholdit.image(format: format)","typeGuard":"def supported_placeholdit_format?(format)\n  Faker::Placeholdit::SUPPORTED_FORMATS.include?(format.to_s.downcase)\nend","tryCatchPattern":"begin\n  Faker::Placeholdit.image(format: format)\nrescue ArgumentError\n  Faker::Placeholdit.image # default png\nend","preventionTips":["Check against the SUPPORTED_FORMATS constant rather than a hardcoded copy.","Only lowercase strings count: :png and 'PNG' both fail.","For formats the gem rejects, build the via.placeholder.com URL manually."],"tags":["faker","argument-error","enum-whitelist","image-url","placeholdit"],"backgroundTag":"invalid-enum-argument","analyzedSha":"cca4184947e09fdd02afb8b89d25a9c8ebc7274e","analyzedAt":"2026-08-21T16:25:39.145Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}