{"record":{"id":"a559acbc1ea7541d","repo":"puppetlabs/puppet","slug":"no-name-provided-in-serialized-data","errorCode":null,"errorMessage":"No name provided in serialized data","messagePattern":"No name provided in serialized data","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/puppet/node.rb","lineNumber":29,"sourceCode":"  # the node sources.\n  extend Puppet::Indirector\n\n  # Asymmetric serialization/deserialization required in this class via to/from datahash\n  include Puppet::Util::PsychSupport\n\n  # Use the node source as the indirection terminus.\n  indirects :node, :terminus_setting => :node_terminus, :doc => \"Where to find node information.\n    A node is composed of its name, its facts, and its environment.\"\n\n  attr_accessor :name, :classes, :source, :ipaddress, :parameters, :environment_name\n  attr_reader :time, :facts, :trusted_data\n\n  attr_reader :server_facts\n\n  ENVIRONMENT = 'environment'\n\n  def initialize_from_hash(data)\n    @name       = data['name']       || (raise ArgumentError, _(\"No name provided in serialized data\"))\n    @classes    = data['classes']    || []\n    @parameters = data['parameters'] || {}\n    env_name = data['environment'] || @parameters[ENVIRONMENT]\n    unless env_name.nil?\n      @parameters[ENVIRONMENT] = env_name\n      @environment_name = env_name.intern\n    end\n  end\n\n  def self.from_data_hash(data)\n    node = new(name)\n    node.initialize_from_hash(data)\n    node\n  end\n\n  def to_data_hash\n    result = {\n      'name' => name,","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/node.rb#L11-L47","documentation":"Puppet::Node#initialize_from_hash restores a node from its serialized form (e.g. a node.yaml produced by a terminus). 'name' is the only mandatory key: classes and parameters default to empty collections, but a missing 'name' raises ArgumentError 'No name provided in serialized data' during deserialization.","triggerScenarios":"Loading a node hash that contains classes/parameters but no 'name' entry: a truncated node.yaml cache, an ENC or external tool emitting the hash without name, or hand-edited YAML where the key was removed.","commonSituations":"Corrupted node caches after crashes; tooling that round-trips nodes through YAML; schema drift where the producer stopped writing the name field.","solutions":["Fix the producer so it writes the node name (the certname) into the serialized hash","If the hash comes from a cache file, delete and regenerate it rather than patching","As recovery, default the name before loading: data['name'] ||= Puppet[:certname]","Validate the YAML structure (Hash with a String 'name') before handing it to initialize_from_hash"],"exampleFix":"# before\ndata = YAML.load_file('node.yaml')            # { 'classes' => [...] }\nnode = Puppet::Node.new('placeholder').tap { |n| n.initialize_from_hash(data) }\n\n# after\ndata = YAML.load_file('node.yaml')\ndata['name'] ||= Puppet[:certname]\nnode = Puppet::Node.new(data['name']).tap { |n| n.initialize_from_hash(data) }","handlingStrategy":"validation","validationCode":"raise ArgumentError, \"serialized node lacks required 'name'\" unless data.is_a?(Hash) && data['name'].is_a?(String) && !data['name'].empty?\nnode = Puppet::Node.new(data['name']).tap { |n| n.initialize_from_hash(data) }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate required keys before deserializing persisted objects","Treat cache files as disposable: regenerate rather than patch corrupted YAML"],"tags":["node","serialization","missing-field","yaml"],"backgroundTag":"missing-required-field","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}