puppetlabs/puppet · error · ArgumentError

Attempt to redefine entity

Error message

Attempt to redefine entity '%{name}'. %{origin_info}

What it means

BaseLoader#fail_redefine: set_entry/promote_entry found an existing entry for the same TypedName and shadowing is not allowed, so the entity would be defined twice in one loader.

Solutions

  1. Remove the duplicate definition
  2. Rename one of the conflicting entities
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at lib/puppet/pops/loader/base_loader.rb:136 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: source

Thrown at lib/puppet/pops/loader/base_loader.rb:136

    synchronize do
      typed_name = named_entry.typed_name
      entry = @named_values[typed_name]
      if entry then fail_redefine(entry); end
      @named_values[typed_name] = named_entry
    end
  end

  protected

  def allow_shadowing?
    false
  end

  private

  def fail_redefine(entry)
    origin_info = entry.origin ? _("Originally set %{original}.") % { original: origin_label(entry.origin) } : _("Set at unknown location")
    raise ArgumentError, _("Attempt to redefine entity '%{name}'. %{origin_info}") % { name: entry.typed_name, origin_info: origin_info }
  end

  # TODO: Should not really be here?? - TODO: A Label provider ? semantics for the URI?
  #
  def origin_label(origin)
    if origin && origin.is_a?(URI)
      format_uri(origin)
    elsif origin.respond_to?(:uri)
      format_uri(origin.uri)
    else
      origin
    end
  end

  def format_uri(uri)
    (uri.scheme == 'puppet' ? 'by ' : 'at ') + uri.to_s.sub(/^puppet:/, '')
  end

View on GitHub (pinned to e227c27540)