{"record":{"id":"75d9cc0fed3e155e","repo":"puppetlabs/puppet","slug":"could-not-intern-from-data-could-not-find-relatio","errorCode":null,"errorMessage":"Could not intern from data: Could not find relationship source %{source} for %{target}","messagePattern":"Could not intern from data: Could not find relationship source %(.+?) for %(.+?)","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/puppet/resource/catalog.rb","lineNumber":437,"sourceCode":"\n    environment = data['environment']\n    if environment\n      result.environment = environment\n      result.environment_instance = Puppet::Node::Environment.remote(environment.to_sym)\n    end\n\n    result.add_resource(\n      *data['resources'].collect do |res|\n        Puppet::Resource.from_data_hash(res)\n      end\n    ) if data['resources']\n\n    if data['edges']\n      data['edges'].each do |edge_hash|\n        edge = Puppet::Relationship.from_data_hash(edge_hash)\n        source = result.resource(edge.source)\n        unless source\n          raise ArgumentError, _(\"Could not intern from data: Could not find relationship source %{source} for %{target}\") %\n                               { source: edge.source.inspect, target: edge.target.to_s }\n        end\n        edge.source = source\n\n        target = result.resource(edge.target)\n        unless target\n          raise ArgumentError, _(\"Could not intern from data: Could not find relationship target %{target} for %{source}\") %\n                               { target: edge.target.inspect, source: edge.source.to_s }\n        end\n        edge.target = target\n\n        result.add_edge(edge)\n      end\n    end\n\n    result.add_class(*data['classes']) if data['classes']\n\n    result.metadata = data['metadata'].transform_values { |v| Puppet::FileServing::Metadata.from_data_hash(v); } if data['metadata']","sourceCodeStart":419,"sourceCodeEnd":455,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/resource/catalog.rb#L419-L455","documentation":"While deserializing a catalog with Puppet::Resource::Catalog.from_data_hash (intern), each entry of data['edges'] is turned into a Puppet::Relationship and its source is resolved against the resources rebuilt from data['resources']. If no resource matches edge.source, ArgumentError is raised: the payload contains a relationship whose source resource was never included.","triggerScenarios":"A serialized catalog hash whose 'resources' list was filtered or hand-edited (a resource removed) while its 'edges' still reference it; producer/consumer Puppet version mismatch changing resource serialization; orchestration or export tooling that builds catalog data hashes itself and forgets edge endpoints.","commonSituations":"Post-processing catalog dumps from PuppetDB or puppet catalog compile; partial payloads after a failed transfer; tests feeding hand-written fixture catalogs with edges pointing at resources never declared.","solutions":["Inspect the payload: collect all \"Type[Title]\" strings from data['resources'] and verify every data['edges'][i]['source'] is present.","Regenerate the serialized catalog from a live compile instead of patching it by hand.","Align the Puppet version of the producer and consumer so resource hashes serialize identically.","If edges are optional metadata, strip dangling edges from the hash before calling from_data_hash."],"exampleFix":"# before\ncatalog = Puppet::Resource::Catalog.from_data_hash(data)\n\n# after — validate edge endpoints first\nrefs = data['resources'].to_a.map { |r| \"#{r['type']}[#{r['title']}]\" }\ndata['edges'].to_a.each do |e|\n  raise ArgumentError, \"payload edge source #{e['source']} has no matching resource\" unless refs.include?(e['source'])\nend\ncatalog = Puppet::Resource::Catalog.from_data_hash(data)","handlingStrategy":"validation","validationCode":"refs = data['resources'].to_a.map { |r| \"#{r['type']}[#{r['title']}]\" }.to_set\ndata['edges'].to_a.each do |e|\n  raise ArgumentError, \"edge source #{e['source']} missing from resources\" unless refs.include?(e['source'])\nend\ncatalog = Puppet::Resource::Catalog.from_data_hash(data)","typeGuard":null,"tryCatchPattern":"begin\n  catalog = Puppet::Resource::Catalog.from_data_hash(data)\nrescue ArgumentError => e\n  raise unless e.message.start_with?('Could not intern from data')\n  raise ArgumentError, \"serialized catalog is inconsistent: #{e.message}\"\nend","preventionTips":["Never hand-edit serialized catalogs; regenerate from a real compile","Round-trip test (to_data_hash -> from_data_hash) any payload you generate","Keep producer and consumer on the same Puppet version when exchanging catalog data"],"tags":["puppet","catalog","deserialization","relationship-edges"],"backgroundTag":"dangling-relationship-reference","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}