{"record":{"id":"684d5ee5ca0c947e","repo":"theforeman/foreman","slug":"invalid-tags-must-be-an-array-of-maps-with-key-an","errorCode":null,"errorMessage":"Invalid tags, must be an array of maps with key and value properties","messagePattern":"Invalid tags, must be an array of maps with key and value properties","errorType":"validation","errorClass":"Foreman::Exception","httpStatus":null,"severity":"error","filePath":"app/models/compute_resources/foreman/model/ec2.rb","lineNumber":71,"sourceCode":"    # Tag Example - <Fog::AWS::Compute::Tag key=nil, value=nil, resource_id=nil, resource_type=nil #>\n    def new_tag(attrs = {})\n      client.tags.new(attrs)\n    end\n\n    def parse_tags(args)\n      # Merge AWS EC2 tags\n      tags = {}\n      if (name = args[:name])\n        tags = {:Name => name}\n      end\n\n      nested_attrs = args.delete(:tags_attributes)\n      args[:tags] = nested_attributes_for(:tags, nested_attrs.deep_symbolize_keys) if nested_attrs\n\n      if args[:tags].present?\n        # Validation, must be [{\"key\": \"tags_name\", \"value\": \"tag_value\"}]\n        if !args[:tags].is_a?(Array) || !args[:tags].all? { |item| item.is_a?(Hash) && item.has_key?(:key) && item.has_key?(:value) }\n          raise Foreman::Exception.new(N_(\"Invalid tags, must be an array of maps with key and value properties\"))\n        end\n        args[:tags].each_with_index do |tag, i|\n          # Validation against AWS rules\n          # https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Using_Tags.html\n          next if tag[:key] =~ /^aws:/\n          next unless tag[:key] =~ /^[\\p{L}\\p{N} +-=._:\\/@]{1,128}$/\n          next unless tag[:value] =~ /^[\\p{L}\\p{N} +-=._:\\/@]{1,256}$/\n          tags[tag[:key]] = tag[:value]\n        end\n      end\n      Foreman::Logging.logger('app').info \"AWS machine #{args[:name]} will be created with tags #{tags}\"\n      tags\n    end\n\n    def create_vm(args = { })\n      args[:tags] = parse_tags(args)\n      args = vm_instance_defaults.merge(args.to_h.symbolize_keys).deep_symbolize_keys\n      if (image_id = args[:image_id])","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/theforeman/foreman/blob/6b05625475cfe6aac31a88f8c8ee6e62e4efe620/app/models/compute_resources/foreman/model/ec2.rb#L53-L89","documentation":"Error \"Invalid tags, must be an array of maps with key and value properties\" thrown in theforeman/foreman.","triggerScenarios":"Thrown at app/models/compute_resources/foreman/model/ec2.rb:71 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"6b05625475cfe6aac31a88f8c8ee6e62e4efe620","analyzedAt":"2026-08-23T17:46:34.094Z","schemaVersion":2},"datasetVersion":"2026-08-23T21:17:23.414Z"}