{"record":{"id":"a92340f420526a03","repo":"Shopify/liquid","slug":"concat-filter-requires-an-array-argument","errorCode":null,"errorMessage":"concat filter requires an array argument","messagePattern":"concat filter requires an array argument","errorType":"exception","errorClass":"Liquid::ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/liquid/standardfilters.rb","lineNumber":706,"sourceCode":"      input = Utils.to_s(input)\n      string = Utils.to_s(string)\n      input + string\n    end\n\n    # @liquid_public_docs\n    # @liquid_type filter\n    # @liquid_category array\n    # @liquid_summary\n    #   Concatenates (combines) two arrays.\n    # @liquid_description\n    #   > Note:\n    #   > The `concat` filter won't filter out duplicates. If you want to remove duplicates, then you need to use the\n    #   > [`uniq` filter](/docs/api/liquid/filters/uniq).\n    # @liquid_syntax array | concat: array\n    # @liquid_return [array[untyped]]\n    def concat(input, array)\n      unless array.respond_to?(:to_ary)\n        raise ArgumentError, \"concat filter requires an array argument\"\n      end\n      InputIterator.new(input, context).concat(array)\n    end\n\n    # @liquid_public_docs\n    # @liquid_type filter\n    # @liquid_category string\n    # @liquid_summary\n    #   Adds a given string to the beginning of a string.\n    # @liquid_syntax string | prepend: string\n    # @liquid_return [string]\n    def prepend(input, string)\n      input = Utils.to_s(input)\n      string = Utils.to_s(string)\n      string + input\n    end\n\n    # @liquid_public_docs","sourceCodeStart":688,"sourceCodeEnd":724,"githubUrl":"https://github.com/Shopify/liquid/blob/807d45a6b3d4568e64e86b375e3702df2c7c860c/lib/liquid/standardfilters.rb#L688-L724","documentation":"The concat Liquid filter requires its filter argument to be an array (anything responding to to_ary). If the second argument is a scalar, string, hash, or nil, it raises Liquid::ArgumentError telling you concat needs an array argument.","triggerScenarios":"Calling {{ a | concat: 'str' }}, {{ a | concat: 5 }}, or {{ a | concat: some_hash }} where the filter argument isn't an array, or the variable is undefined/nil.","commonSituations":"Assuming concat joins strings (it merges arrays); passing a variable that was never assign'd; passing a hash or scalar from shop/metafield data; typos so the array variable is nil.","solutions":["Pass an array as the argument: {% assign b = a | concat: other_array %}","Split strings into arrays first if you intended string joining (use append or split)","Verify the argument variable is defined as an array before the concat filter"],"exampleFix":"<!-- before -->\n{{ tags | concat: 'sale' }}\n<!-- after -->\n{% assign extra = 'sale' | split: ',' %}\n{{ tags | concat: extra }}","handlingStrategy":"type-guard","validationCode":"{% unless extra %}{% assign extra = '' | split: ',' %}{% endunless %}","typeGuard":"def array_arg?(v)\n  v.respond_to?(:to_ary)\nend","tryCatchPattern":"begin\n  output = Liquid::Template.parse(tpl).render(assigns)\nrescue Liquid::ArgumentError => e\n  raise unless e.message.include?('concat filter')\n  # log and render without the concatenation\nend","preventionTips":["Remember concat merges arrays, not strings","Default undefined variables to arrays via split: ''","Validate data shapes from metafields before templating"],"tags":["liquid","template-engine","filter","type-error","array"],"backgroundTag":"type-mismatch","analyzedSha":"807d45a6b3d4568e64e86b375e3702df2c7c860c","analyzedAt":"2026-09-08T11:31:38.917Z","contentChangedAt":"2026-09-08T11:31:38.917Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}