puppetlabs/puppet · error · ArgumentError
Could not intern from data: Could not find relationship targ
Error message
Could not intern from data: Could not find relationship target %{target} for %{source} What it means
Companion to the source check in Puppet::Resource::Catalog.from_data_hash: after the edge source is resolved, the target is looked up via result.resource(edge.target); if absent, ArgumentError is raised with the target ref and the source name. The serialized catalog data is internally inconsistent — a relationship points at a resource that was not in data['resources'].
Source
Thrown at lib/puppet/resource/catalog.rb:444
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']
recursive_metadata = data['recursive_metadata']
if recursive_metadata
result.recursive_metadata = recursive_metadata.transform_values do |source_to_meta_hash|
source_to_meta_hash.transform_values do |metas|
metas.map { |meta| Puppet::FileServing::Metadata.from_data_hash(meta) }
endView on GitHub (pinned to e227c27540)
Solutions
- Diff the refs of data['resources'] against every data['edges'][i]['target'] and add the missing resource back or drop the edge.
- Regenerate the payload from a real compilation (puppet catalog compile / agent run) rather than editing it.
- Pin producer and consumer to the same Puppet major/minor so ref serialization matches.
- Unit-test the payload with a round-trip (to_data_hash -> from_data_hash) before shipping it.
Example fix
# before
catalog = Puppet::Resource::Catalog.from_data_hash(data)
# after — check both endpoints before interning
refs = data['resources'].to_a.map { |r| "#{r['type']}[#{r['title']}]" }.to_set
data['edges'].to_a.each do |e|
%w[source target].each do |side|
raise ArgumentError, "edge #{side} #{e[side]} missing from resources" unless refs.include?(e[side])
end
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|
%w[source target].each do |side|
raise ArgumentError, "edge #{side} #{e[side]} missing from resources" unless refs.include?(e[side])
end
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')
# drop dangling edges and retry, or fail loudly with payload context
raise ArgumentError, "inconsistent catalog payload: #{e.message}"
end Prevention
- When filtering resources from a catalog hash, always recompute the edges list in the same pass
- Treat catalog payloads as immutable derived data — edit the manifests instead
- Assert edge/resource consistency in fixture tests before from_data_hash
When it happens
Trigger: A catalog data hash whose edges reference a target resource missing from the resources array (filtering removed it, or the producer never included it); mixed-version serialization where the target's ref string format changed; fixtures built by hand that declare require/notify edges without both endpoints.
Common situations: Editing or pruning catalog dumps and forgetting dependent edges; CI fixtures for catalog round-trips; tooling that appends custom edges (e.g. ordering hooks) referencing resources it never adds.
Related errors
- Could not intern from data: Could not find relationship sour
- Unable to verify the SSL certificate at %{uri}
- No title provided and %{type} is not a valid resource refere
- Could not find resource '%{res}' in parameter '%{param}'
- Duplicate declaration: %{resource} is already declared; cann
AI-assisted analysis of puppetlabs/puppet@e227c27540 (2026-08-21).
Data as JSON: /api/errors/44cdab1677b796ed.
Report an issue: GitHub.