{"record":{"id":"7651e4f08a2f71fa","repo":"faker-ruby/faker","slug":"search-terms-must-be-specified-for-pixelated-image","errorCode":null,"errorMessage":"Search terms must be specified for pixelated images","messagePattern":"Search terms must be specified for pixelated images","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/faker/default/lorem_flickr.rb","lineNumber":67,"sourceCode":"\n      ##\n      # Produces a random pixelated image URL from loremflickr.com.\n      #\n      # @param size [String] Specifies the size of image to generate.\n      # @param search_terms [Array<String>] Adds search terms to the image URL.\n      # @param match_all [Boolean] Add \"all\" as part of the URL.\n      # @return [String]\n      #\n      # @example\n      #   Faker::LoremFlickr.pixelated_image #=> \"https://loremflickr.com/p/300/300/all\"\n      #   Faker::LoremFlickr.pixelated_image(size: \"50x60\") #=> \"https://loremflickr.com/p/50/60/all\"\n      #   Faker::LoremFlickr.pixelated_image(size: \"50x60\", search_terms: ['sports']) #=> \"https://loremflickr.com/p/50/60/sports\"\n      #   Faker::LoremFlickr.pixelated_image(size: \"50x60\", search_terms: ['sports', 'fitness']) #=> \"https://loremflickr.com/p/50/60/sports,fitness\"\n      #   Faker::LoremFlickr.pixelated_image(size: \"50x60\", search_terms: ['sports', 'fitness'], match_all: true) #=> \"https://loremflickr.com/p/50/60/sports,fitness/all\"\n      #\n      # @faker.version 1.9.0\n      def pixelated_image(size: '300x300', search_terms: ['all'], match_all: false)\n        raise ArgumentError, 'Search terms must be specified for pixelated images' unless search_terms.any?\n\n        build_url(size, 'p', search_terms, match_all)\n      end\n\n      ##\n      # Produces a random colorized image URL from loremflickr.com.\n      #\n      # @param size [String] Specifies the size of image to generate.\n      # @param color [String] Specifies the color of image to generate.\n      # @param search_terms [Array<String>] Adds search terms to the image URL.\n      # @param match_all [Boolean] Add \"all\" as part of the URL.\n      # @return [String]\n      #\n      # @example\n      #   Faker::LoremFlickr.image #=> \"https://loremflickr.com/red/300/300/all\"\n      #   Faker::LoremFlickr.image(size: \"50x60\", color: 'blue') #=> \"https://loremflickr.com/blue/50/60/all\"\n      #   Faker::LoremFlickr.image(size: \"50x60\", color: 'blue', search_terms: ['sports']) #=> \"https://loremflickr.com/blue/50/60/sports\"\n      #   Faker::LoremFlickr.image(size: \"50x60\", color: 'blue', search_terms: ['sports', 'fitness']) #=> \"https://loremflickr.com/blue/50/60/sports,fitness\"","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/faker-ruby/faker/blob/cca4184947e09fdd02afb8b89d25a9c8ebc7274e/lib/faker/default/lorem_flickr.rb#L49-L85","documentation":"Raised by Faker::LoremFlickr.pixelated_image when the search_terms array is empty. Like the grayscale variant, the LoremFlickr pixelated URL requires at least one search keyword segment, so `search_terms.any?` is enforced before build_url runs.","triggerScenarios":"Faker::LoremFlickr.pixelated_image(search_terms: []) — e.g. splitting an empty user query (`''.split(',')`) or filtering a tag list down to nothing before passing it.","commonSituations":"Controllers/helpers that pass `search_terms: params[:keywords].to_s.split(',')` and forget the blank case; view code that composes tags from optional filters; copy-pasting the grayscale example with dynamic terms.","solutions":["Pass at least one term, e.g. search_terms: ['all'] or ['city'].","Fallback when the source list is blank: `terms.empty? ? ['all'] : terms`.","Validate in the calling layer that user-provided keyword lists are non-empty before reaching Faker."],"exampleFix":"# before\nFaker::LoremFlickr.pixelated_image(search_terms: query.split(',')) # query == ''\n\n# after\nterms = query.split(',')\nterms = ['all'] if terms.empty?\nFaker::LoremFlickr.pixelated_image(search_terms: terms)","handlingStrategy":"validation","validationCode":"terms = query.to_s.split(',').map(&:strip).reject(&:empty?)\nterms = ['all'] if terms.empty?\nFaker::LoremFlickr.pixelated_image(search_terms: terms)","typeGuard":"def non_blank_terms?(terms)\n  terms.is_a?(Array) && terms.compact.any? { |t| t.to_s.strip != '' }\nend","tryCatchPattern":"begin\n  Faker::LoremFlickr.pixelated_image(search_terms: terms)\nrescue ArgumentError\n  Faker::LoremFlickr.pixelated_image(search_terms: ['all'])\nend","preventionTips":["Never pass ''.split(',') output unchecked; it yields [].","Default empty keyword lists to ['all'] at the controller/helper boundary.","Share one normalization helper across grayscale/pixelated/colorized variants."],"tags":["faker","argument-error","validation","image-url","loremflickr"],"backgroundTag":"empty-collection-argument","analyzedSha":"cca4184947e09fdd02afb8b89d25a9c8ebc7274e","analyzedAt":"2026-08-21T16:25:39.145Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}