hashicorp/vagrant · error · Vagrant::Errors::TriggersNoStageGiven

The incorrect stage was given to the trigger plugin: Guest:

Error message

The incorrect stage was given to the trigger plugin:
Guest: %{guest_name}
Name:  %{name}
Type:  %{type}
Stage: %{stage}

This is an internal error that should be reported as a bug.

What it means

Internal invariant error in Vagrant::Plugin::V2::Trigger#find: the `stage` argument was neither :before nor :after, so no trigger set could be selected and the else branch raised (lib/vagrant/plugin/v2/trigger.rb:89). The message itself says this is an internal error that should be reported as a bug — it cannot be produced by any supported Vagrantfile trigger configuration, which only ever passes :before/:after.

Source

Thrown at lib/vagrant/plugin/v2/trigger.rb:89

        # @return [Array]
        def find(name, stage, guest, type, all: false)
          triggers = nil
          name = nameify(name)

          if stage == :before
            triggers = config.before_triggers.select do |t|
              (all && t.command.respond_to?(:to_sym) && t.command.to_sym == :all && !t.ignore.include?(name.to_sym)) ||
                (type == :hook && matched_hook?(t.command, name)) ||
                nameify(t.command) == name
            end
          elsif stage == :after
            triggers = config.after_triggers.select do |t|
              (all && t.command.respond_to?(:to_sym) && t.command.to_sym == :all && !t.ignore.include?(name.to_sym)) ||
                (type == :hook && matched_hook?(t.command, name)) ||
                nameify(t.command) == name
            end
          else
            raise Errors::TriggersNoStageGiven,
              name: name,
              stage: stage,
              type: type,
              guest_name: guest
          end

          filter_triggers(triggers, guest, type)
        end

        protected

        # Convert object into name
        #
        # @param [Object, Class] object Object to name
        # @return [String]
        def nameify(object)
          if object.is_a?(Class)
            object.name.to_s

View on GitHub (pinned to 35f3160f4a)

Solutions

  1. Upgrade Vagrant to a release where the trigger-stage bug is fixed — check the changelog for trigger fixes
  2. Report a bug as the message instructs: include Vagrant version, the Vagrantfile, and the backtrace
  3. If a third-party trigger-related plugin is installed, update or remove it and re-test to rule out interference
Defensive patterns

Strategy: validation

Validate before calling

raise ArgumentError, "stage must be :before or :after, got #{stage.inspect}" unless %i[before after].include?(stage)

Type guard

# Ruby guard before calling Trigger#find or wrappers around it
def valid_trigger_stage?(stage)
  %i[before after].include?(stage)
end

Prevention

When it happens

Trigger: Vagrant core code (or a plugin monkey-patching Trigger internals) invoking the trigger lookup with a wrong stage symbol — e.g. a typo'd or newly introduced stage value that the if/elsif chain does not cover. Reached on any command that fires triggers once the bad stage is passed in.

Common situations: A regression in a specific Vagrant release's trigger scheduling; third-party plugins that wrap or re-implement Trigger#find with custom stage values; forks patched to add stages (e.g. :during) without extending this method.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of hashicorp/vagrant@35f3160f4a (2026-08-21). Data as JSON: /api/errors/290c31da83000432. Report an issue: GitHub.