{"record":{"id":"9b1c367ee82ad72d","repo":"puppetlabs/puppet","slug":"role-names-must-be-provided-as-an-array-not-a-com","errorCode":null,"errorMessage":"Role names must be provided as an array, not a comma-separated list","messagePattern":"Role names must be provided as an array, not a comma-separated list","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/puppet/type/user.rb","lineNumber":529,"sourceCode":"    # @return [Boolean] if the user exists on the system\n    # @api private\n    def exists?\n      provider.exists?\n    end\n\n    newproperty(:roles, :parent => Puppet::Property::List, :required_features => :manages_roles) do\n      desc \"The roles the user has.  Multiple roles should be\n        specified as an array.\"\n\n      def membership\n        :role_membership\n      end\n\n      validate do |value|\n        if value =~ /^\\d+$/\n          raise ArgumentError, _(\"Role names must be provided, not numbers\")\n        end\n        raise ArgumentError, _(\"Role names must be provided as an array, not a comma-separated list\") if value.include?(\",\")\n      end\n    end\n\n    # autorequire the roles that the user has\n    autorequire(:user) do\n      reqs = []\n\n      roles_property = @parameters[:roles]\n      roles = roles_property.should if roles_property\n      if roles\n        reqs += roles.split(',')\n      end\n\n      reqs\n    end unless Puppet::Util::Platform.windows?\n\n    newparam(:role_membership) do\n      desc \"Whether specified roles should be considered the **complete list**","sourceCodeStart":511,"sourceCodeEnd":547,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/type/user.rb#L511-L547","documentation":"Raised by the validate block of the `roles` property on the `user` type when a member string contains a comma. Like `groups`, the property expects an array of role names (Puppet::Property::List); a single comma-joined string is rejected instead of being silently split or misread as one role name.","triggerScenarios":"`user { 'alice': roles => 'sysadmin,webadmin' }` on a provider with manages_roles; a Hiera string built by joining an array; ENC output that only carries string parameters.","commonSituations":"Porting `usermod -R sysadm,audit` style commands; Ruby interpolation of arrays into role parameters; older YAML data authored as comma lists.","solutions":["Pass an array: `roles => ['sysadmin', 'webadmin']`","Store a YAML list in Hiera instead of a joined string","Split incoming strings in the profile: `roles => $raw.split(',')`"],"exampleFix":"# before\nuser { 'alice':\n  ensure => present,\n  roles  => 'sysadmin,webadmin',\n}\n\n# after\nuser { 'alice':\n  ensure => present,\n  roles  => ['sysadmin', 'webadmin'],\n}","handlingStrategy":"validation","validationCode":"# Accept scalar or array, normalize to array of names\nroles = raw.is_a?(String) ? raw.split(',').map(&:strip).reject(&:empty?) : Array(raw)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Author roles as arrays in YAML/Hiera","Never copy 'usermod -R a,b' comma syntax into manifests","Split incoming scalars in the profile boundary layer"],"tags":["puppet","user-resource","solaris-rbac","roles","list-validation"],"backgroundTag":"string-list-instead-of-array","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}