{"record":{"id":"211cdb2591f3a92f","repo":"puppetlabs/puppet","slug":"failed-to-realize-virtual-resources-resources","errorCode":null,"errorMessage":"Failed to realize virtual resources %{resources}","messagePattern":"Failed to realize virtual resources %(.+?)","errorType":"exception","errorClass":"Puppet::ParseError","httpStatus":null,"severity":"error","filePath":"lib/puppet/parser/compiler.rb","lineNumber":426,"sourceCode":"  # If there are any resource overrides remaining, then we could\n  # not find the resource they were supposed to override, so we\n  # want to throw an exception.\n  def fail_on_unevaluated_overrides\n    remaining = @resource_overrides.values.flatten.collect(&:ref)\n\n    unless remaining.empty?\n      raise Puppet::ParseError, _(\"Could not find resource(s) %{resources} for overriding\") % { resources: remaining.join(', ') }\n    end\n  end\n\n  # Make sure there are no remaining collections that are waiting for\n  # resources that have not yet been instantiated. If this occurs it\n  # is an error (missing resource - it could not be realized).\n  #\n  def fail_on_unevaluated_resource_collections\n    remaining = @collections.collect(&:unresolved_resources).flatten.compact\n    unless remaining.empty?\n      raise Puppet::ParseError, _(\"Failed to realize virtual resources %{resources}\") % { resources: remaining.join(', ') }\n    end\n  end\n\n  # Make sure all of our resources and such have done any last work\n  # necessary.\n  def finish\n    evaluate_relationships\n\n    resources.each do |resource|\n      # Add in any resource overrides.\n      overrides = resource_overrides(resource)\n      if overrides\n        overrides.each do |over|\n          resource.merge(over)\n        end\n\n        # Remove the overrides, so that the configuration knows there\n        # are none left.","sourceCodeStart":408,"sourceCodeEnd":444,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/parser/compiler.rb#L408-L444","documentation":"After compilation, fail_on_unevaluated_resource_collections checks every collection (realize() statements and virtual-resource collectors) for unresolved resources. A realize(Virtual_resource['x']) whose target was never declared as a virtual resource anywhere in the compiled code leaves an unresolved entry, and Puppet::ParseError 'Failed to realize virtual resources' lists them. Tag collectors that simply match nothing are fine - only explicitly waited-for refs that never appeared fail.","triggerScenarios":"realize(File['/etc/app.conf']) where no @file { '/etc/app.conf': ... } virtual declaration exists; the declaring class was removed or not included; title mismatch between the @declaration and the realize() ref.","commonSituations":"Deleting a virtual declaration but leaving its realize behind; realize in shared site.pp for resources provided by a class only some nodes include; ref spelling/casing drift.","solutions":["Declare the resource virtual before realizing: @file { '/etc/app.conf': ... } or include the class that declares it","Remove the stray realize() for resources that no longer exist","Prefer tag collectors (File<| tag == 'app' |>) which tolerate zero matches"],"exampleFix":"// before\nrealize(File['/etc/app.conf'])\n\n// after\n@file { '/etc/app.conf': ensure => file, mode => '0644' }\nrealize(File['/etc/app.conf'])","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"begin\n  compiler.compile\nrescue Puppet::ParseError => e\n  if (m = e.message.match(/Failed to realize virtual resources (.+)/))\n    unrealized = m[1].split(', ')\n  end\n  raise\nend","preventionTips":["Every realize(Resource['x']) must have a matching @resource { 'x': } declaration in the compiled code","Prefer tag collectors (Resource<| tag == 'x' |>) over per-title realize - empty matches are not an error","When removing a virtual declaration, grep for its realize() at the same time"],"tags":["puppet","virtual-resources","realize","dsl","catalog"],"backgroundTag":"unrealized-virtual-resources","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}