opf/openproject · error · ArgumentError

Invalid step: #{step}

Error message

Invalid step: #{step}

What it means

Admin::Import::Jira::ImportRunsController#change_step dispatches wizard navigation: it only accepts step values present in the controller's VALID_STEPS whitelist and calls the matching instance method. Any other non-blank step param raises ArgumentError('Invalid step: #{step}'), which surfaces as a 500/handled error rather than a wizard transition.

Source

Thrown at app/controllers/admin/import/jira/import_runs_controller.rb:100

    def remove
      raise StandardError.new(I18n.t(:"admin.jira.run.remove_error")) if @jira_import.status_running?

      @jira_import.destroy!
      redirect_to admin_import_jira_path(@jira), status: :see_other
    end

    def history
      @history = @jira_import.history
    end

    private

    def change_step(step)
      return if step.blank?

      method_name = VALID_STEPS.detect { |i| i == step.to_sym }
      raise ArgumentError, "Invalid step: #{step}" unless method_name

      send(method_name)
    end

    def handle_error(error)
      respond_to do |format|
        format.turbo_stream do
          render_error_flash_message_via_turbo_stream(message: error.message.to_s)
          respond_with_turbo_streams
        end
        format.html do
          flash[:error] = error.message
          redirect_to(admin_import_jira_run_path(jira_id: @jira.id, id: @jira_import.id))
        end
      end
    end

    def fetch_instance_meta

View on GitHub (pinned to d9742c43f3)

Solutions

  1. Reload the Jira import wizard page (fresh HTML/JS) and navigate with the shipped buttons only.
  2. Compare the step value in the failing request params against VALID_STEPS in this controller — if a legitimate step is missing, the form and controller are out of sync (version mismatch).
  3. If you customized the wizard, add your step symbol to VALID_STEPS alongside a handler method of the same name.

Example fix

# before
change_step(params[:step])

# after (fail soft on unknown steps)
step = params[:step]
return if step.blank? || VALID_STEPS.exclude?(step.to_sym)
change_step(step)
Defensive patterns

Strategy: validation

Validate before calling

step = params[:step].to_s
return if step.blank?
raise ArgumentError, "Invalid step: #{step}" unless Admin::Import::Jira::ImportRunsController::VALID_STEPS.include?(step.to_sym)

Try / catch

begin
  change_step(params[:step])
rescue ArgumentError
  redirect_to admin_import_jira_path, alert: 'Unknown wizard step — reload the page'
end

Prevention

When it happens

Trigger: POSTing the import-run form with step=<anything not in VALID_STEPS> — e.g. a stale browser tab running an older wizard version whose form emits a renamed step, a hand-crafted request, or a JavaScript hook submitting an intermediate value.

Common situations: Upgrading OpenProject while the admin has the Jira import wizard open in a tab (old assets submit old step names); a plugin or customization altering the wizard form; bookmarked form URLs replayed after an upgrade.

Related errors


AI-assisted analysis of opf/openproject@d9742c43f3 (2026-08-21). Data as JSON: /api/errors/d81f3901cb008c98. Report an issue: GitHub.