puppetlabs/puppet · error · ArgumentError

Could not intern from data: Could not find relationship sour

Error message

Could not intern from data: Could not find relationship source %{source} for %{target}

What it means

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.

Source

Thrown at lib/puppet/resource/catalog.rb:437

    environment = data['environment']
    if environment
      result.environment = environment
      result.environment_instance = Puppet::Node::Environment.remote(environment.to_sym)
    end

    result.add_resource(
      *data['resources'].collect do |res|
        Puppet::Resource.from_data_hash(res)
      end
    ) if data['resources']

    if data['edges']
      data['edges'].each do |edge_hash|
        edge = Puppet::Relationship.from_data_hash(edge_hash)
        source = result.resource(edge.source)
        unless source
          raise ArgumentError, _("Could not intern from data: Could not find relationship source %{source} for %{target}") %
                               { source: edge.source.inspect, target: edge.target.to_s }
        end
        edge.source = source

        target = result.resource(edge.target)
        unless target
          raise ArgumentError, _("Could not intern from data: Could not find relationship target %{target} for %{source}") %
                               { target: edge.target.inspect, source: edge.source.to_s }
        end
        edge.target = target

        result.add_edge(edge)
      end
    end

    result.add_class(*data['classes']) if data['classes']

    result.metadata = data['metadata'].transform_values { |v| Puppet::FileServing::Metadata.from_data_hash(v); } if data['metadata']

View on GitHub (pinned to e227c27540)

Solutions

  1. Inspect the payload: collect all "Type[Title]" strings from data['resources'] and verify every data['edges'][i]['source'] is present.
  2. Regenerate the serialized catalog from a live compile instead of patching it by hand.
  3. Align the Puppet version of the producer and consumer so resource hashes serialize identically.
  4. If edges are optional metadata, strip dangling edges from the hash before calling from_data_hash.

Example fix

# before
catalog = Puppet::Resource::Catalog.from_data_hash(data)

# after — validate edge endpoints first
refs = data['resources'].to_a.map { |r| "#{r['type']}[#{r['title']}]" }
data['edges'].to_a.each do |e|
  raise ArgumentError, "payload edge source #{e['source']} has no matching resource" unless refs.include?(e['source'])
end
catalog = Puppet::Resource::Catalog.from_data_hash(data)
Defensive patterns

Strategy: validation

Validate before calling

refs = data['resources'].to_a.map { |r| "#{r['type']}[#{r['title']}]" }.to_set
data['edges'].to_a.each do |e|
  raise ArgumentError, "edge source #{e['source']} missing from resources" unless refs.include?(e['source'])
end
catalog = Puppet::Resource::Catalog.from_data_hash(data)

Try / catch

begin
  catalog = Puppet::Resource::Catalog.from_data_hash(data)
rescue ArgumentError => e
  raise unless e.message.start_with?('Could not intern from data')
  raise ArgumentError, "serialized catalog is inconsistent: #{e.message}"
end

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of puppetlabs/puppet@e227c27540 (2026-08-21). Data as JSON: /api/errors/75d9cc0fed3e155e. Report an issue: GitHub.