{"record":{"id":"9cc2e992db8a2e6a","repo":"puppetlabs/puppet","slug":"could-not-set-the-dscl-keyname-key-with-value","errorCode":null,"errorMessage":"Could not set the dscl #{keyname} key with value: #{value} - #{detail.inspect}","messagePattern":"Could not set the dscl #(.+?) key with value: #(.+?) - #(.+?)","errorType":"exception","errorClass":"Puppet::Error","httpStatus":null,"severity":"error","filePath":"lib/puppet/provider/user/directoryservice.rb","lineNumber":508,"sourceCode":"\n  def self.password_hash_dir\n    '/var/db/shadow/hash'\n  end\n\n  # This method will create a given value using dscl\n  def create_attribute_with_dscl(path, username, keyname, value)\n    set_attribute_with_dscl('-create', path, username, keyname, value)\n  end\n\n  # This method will merge in a given value using dscl\n  def merge_attribute_with_dscl(path, username, keyname, value)\n    set_attribute_with_dscl('-merge', path, username, keyname, value)\n  end\n\n  def set_attribute_with_dscl(dscl_command, path, username, keyname, value)\n    dscl '.', dscl_command, \"/#{path}/#{username}\", keyname, value\n  rescue Puppet::ExecutionFailure => detail\n    raise Puppet::Error, \"Could not set the dscl #{keyname} key with value: #{value} - #{detail.inspect}\", detail.backtrace\n  end\n\n  # Create the new user with dscl\n  def create_new_user(username)\n    dscl '.', '-create', \"/Users/#{username}\"\n  end\n\n  # Get the next available uid on the system by getting a list of user ids,\n  # sorting them, grabbing the last one, and adding a 1. Scientific stuff here.\n  def next_system_id(min_id = 20)\n    dscl_output = dscl '.', '-list', '/Users', 'uid'\n    # We're ok with throwing away negative uids here. Also, remove nil values.\n    user_ids = dscl_output.split.compact.collect { |l| l.to_i if l =~ /^\\d+$/ }\n    ids = user_ids.compact!.sort_by!(&:to_f)\n    # We're just looking for an unused id in our sorted array.\n    ids.each_index do |i|\n      next_id = ids[i] + 1\n      return next_id if ids[i + 1] != next_id and next_id >= min_id","sourceCodeStart":490,"sourceCodeEnd":526,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/provider/user/directoryservice.rb#L490-L526","documentation":"Error \"Could not set the dscl #{keyname} key with value: #{value} - #{detail.inspect}\" thrown in puppetlabs/puppet.","triggerScenarios":"Thrown at lib/puppet/provider/user/directoryservice.rb:508 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":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}