{"record":{"id":"5f4de479cc6bc277","repo":"faker-ruby/faker","slug":"search-terms-must-be-specified-for-colorized-image","errorCode":null,"errorMessage":"Search terms must be specified for colorized images","messagePattern":"Search terms must be specified for colorized images","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/faker/default/lorem_flickr.rb","lineNumber":90,"sourceCode":"      ##\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\"\n      #   Faker::LoremFlickr.image(size: \"50x60\", color: 'blue', search_terms: ['sports', 'fitness'], match_all: true) #=> \"https://loremflickr.com/blue/50/60/sports,fitness/all\"\n      #\n      # @faker.version 1.9.0\n      def colorized_image(size: '300x300', color: 'red', search_terms: ['all'], match_all: false)\n        raise ArgumentError, 'Search terms must be specified for colorized images' unless search_terms.any?\n        raise ArgumentError, \"Supported colorizations are #{SUPPORTED_COLORIZATIONS.join(', ')}\" unless SUPPORTED_COLORIZATIONS.include?(color)\n\n        build_url(size, color, search_terms, match_all)\n      end\n\n      private\n\n      def build_url(size, format, search_terms, match_all)\n        raise ArgumentError, 'Size should be specified in format 300x300' unless size =~ /\\A[0-9]+x[0-9]+\\z/\n\n        url_parts = ['https://loremflickr.com']\n        url_parts << format\n        url_parts += size.split('x')\n        url_parts << search_terms.compact.join(',') if search_terms.any?\n        url_parts << 'all' if match_all\n        url_parts.compact.join('/')\n      end\n    end","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/faker-ruby/faker/blob/cca4184947e09fdd02afb8b89d25a9c8ebc7274e/lib/faker/default/lorem_flickr.rb#L72-L108","documentation":"Raised by Faker::LoremFlickr.colorized_image when the search_terms array is empty. It is the first of two guards in the method (the second validates the color), and fires because the colorized LoremFlickr URL needs at least one keyword after the color segment.","triggerScenarios":"Faker::LoremFlickr.colorized_image(color: 'blue', search_terms: []) — an empty array (or one containing only nil) fails `search_terms.any?` at lib/faker/default/lorem_flickr.rb:90.","commonSituations":"Passing a programmatically built tag list that can be empty; the colorized variant is checked before the color, so a call with both a bad color and empty terms reports the search-terms error first, which can mislead debugging.","solutions":["Pass a non-empty array, e.g. search_terms: ['all'].","Coalesce blank lists to ['all'] before calling.","Remember this guard runs before the color check; fix the terms first, then verify the color is red/green/blue."],"exampleFix":"# before\nFaker::LoremFlickr.colorized_image(color: 'blue', search_terms: []) # ArgumentError\n\n# after\nFaker::LoremFlickr.colorized_image(color: 'blue', search_terms: ['all'])","handlingStrategy":"validation","validationCode":"terms = tags.to_a.compact\nFaker::LoremFlickr.colorized_image(color: 'blue', search_terms: terms.empty? ? ['all'] : 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.colorized_image(color: color, search_terms: terms)\nrescue ArgumentError\n  Faker::LoremFlickr.colorized_image(color: color) # defaults handle both guards\nend","preventionTips":["This guard fires before the color guard — fix terms first when debugging.","Default empty tag lists to ['all'].","Validate color against SUPPORTED_COLORIZATIONS in the same helper."],"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"}