theforeman/foreman · error · RuntimeError
The specified snippet '#{name}' does not exist, or is not a
Error message
The specified snippet '#{name}' does not exist, or is not a snippet. What it means
Error "The specified snippet '#{name}' does not exist, or is not a snippet." thrown in theforeman/foreman.
Source
Thrown at app/services/foreman/renderer/scope/macros/snippet_rendering.rb:51
parametrized using variables.
The snippet rendering happens in the same context as the main template rendering, meaning all instance
variables and macros are available in that snippet. Variables passed to this snippet are available
only during the snippet rendering.'
required :name, String, desc: 'Name of the snippet template to render'
optional :options, Hash, desc: 'Rendering options, the only supported option is +variables+ which can also be set by specific keyword argument',
default: {}
optional :variables, Hash, desc: 'Every key will be registered as instance variable, e.g. key +enable_ntp+ will be available as +@enable_ntp+',
default: {}
returns String, desc: 'evaluated ERB of the snippet'
raises error: StandardError, desc: 'in case the snippet was not found in the current template source, e.g. a database.'
raises error: Foreman::Exception, desc: 'in case the snippet raised exception during rendering.'
example "snippet('motd') # => 'Hello world'"
example "snippet('ntp_server', variables: { :enable_ntp => true) } # => '...'"
end
def snippet(name, options = {}, variables: {})
template = source.find_snippet(name)
unless template
raise "The specified snippet '#{name}' does not exist, or is not a snippet." unless options[:silent]
return
end
begin
snippet_variables = variables_keys.index_with { |key| instance_variable_get("@#{key}") }
.symbolize_keys
.merge(variables)
.merge(options[:variables] || {})
template.render(renderer: renderer, host: host, variables: snippet_variables, params: params, mode: mode, source_klass: source&.class)
rescue ::Foreman::Exception => e
Foreman::Logging.exception('Error while rendering a snippet', e)
raise
rescue StandardError => exc
e = ::Foreman::Exception.new(N_("The snippet '%{name}' threw an error: %{exc}"), { :name => name, :exc => exc })
e.set_backtrace exc.backtrace
raise e
end
endView on GitHub (pinned to 6b05625475)
When it happens
Trigger: Thrown at app/services/foreman/renderer/scope/macros/snippet_rendering.rb:51 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of theforeman/foreman@6b05625475 (2026-08-23).
Data as JSON: /api/errors/2757fe81f1c1742a.
Report an issue: GitHub.