hashicorp/nomad · error

Invalid event hook given

Error message

Invalid event hook given

What it means

Sentinel validation guard in TaskTemplateManagerConfig.Validate: the Events channel was not set, so template render events could not be delivered to the task runner. Raised from NewTaskTemplateManager when the config struct was built without an event hook.

Source

Thrown at client/allocrunner/taskrunner/template/template.go:158

	Logger hclog.Logger

	// RenderFunc allows custom rendering of templated data, and overrides the
	// Nomad custom RenderFunc used for sandboxing. This is currently used by
	// the secrets block to hold all templated data in memory.
	RenderFunc renderer.Renderer
}

// Validate validates the configuration.
func (c *TaskTemplateManagerConfig) Validate() error {
	if c == nil {
		return fmt.Errorf("Nil config passed")
	} else if c.UnblockCh == nil {
		return fmt.Errorf("Invalid unblock channel given")
	} else if c.Lifecycle == nil {
		return fmt.Errorf("Invalid lifecycle hooks given")
	} else if c.Events == nil {
		return fmt.Errorf("Invalid event hook given")
	} else if c.ClientConfig == nil {
		return fmt.Errorf("Invalid client config given")
	} else if c.TaskDir == "" {
		return fmt.Errorf("Invalid task directory given: %q", c.TaskDir)
	} else if c.EnvBuilder == nil {
		return fmt.Errorf("Invalid task environment given")
	} else if c.MaxTemplateEventRate == 0 {
		return fmt.Errorf("Invalid max template event rate given")
	}

	// Once is a runner config, but in Nomad it is set per template, so all
	// templates given to a runner should have the same value for Once.
	var once bool
	for i, t := range c.Templates {
		if i == 0 {
			once = t.Once
		} else if t.Once != once {
			return fmt.Errorf("All templates should have same Once value")

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Assign a valid Events channel on TaskTemplateManagerConfig before constructing the manager
  2. Check the config-building code path so the event hook is always wired up
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at client/allocrunner/taskrunner/template/template.go:158 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04). Data as JSON: /api/errors/4555cd14c0347234. Report an issue: GitHub.