opf/openproject · error · StandardError
A Jira import run cannot be removed while it is running
Error message
A Jira import run cannot be removed while it is running
What it means
Admin::Import::Jira::ImportRunsController#remove refuses to destroy a JiraImport record while its status is 'running' (jira_import.status_running?). It raises StandardError carrying the 'admin.jira.run.remove_error' locale message, which the controller's handle_error renders as a flash/turbo-stream error instead of redirecting. The guard protects the running JiraImportProjectsJob background job from losing its import record mid-run.
Source
Thrown at app/controllers/admin/import/jira/import_runs_controller.rb:84
end
rescue StandardError => e
handle_error(e)
end
def import_modal
respond_with_dialog Admin::Import::Jira::ImportRuns::ImportConfirmDialogComponent.new(jira_import: @jira_import)
end
def revert_modal
respond_with_dialog Admin::Import::Jira::ImportRuns::RevertConfirmDialogComponent.new(jira_import: @jira_import)
end
def finalize_modal
respond_with_dialog Admin::Import::Jira::ImportRuns::FinalizeConfirmDialogComponent.new(jira_import: @jira_import)
end
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)View on GitHub (pinned to d9742c43f3)
Solutions
- Wait for the import run to actually finish: check the background worker (GoodJob dashboard / logs) for the JiraImportProjectsJob processing that run, then retry Remove.
- If the job is gone but the row is stuck at 'running', finish the run through the wizard's own Finalize/Revert actions instead of Remove (revert_modal/finalize_modal actions exist on this controller).
- If no job exists and revert/finalize are not applicable, reset the stale status in a Rails console (e.g. jira_import.update_column(:status, :failed)) and then Remove.
- Search for orphaned/errored jobs (GoodJob) and clean them up so the status machine can advance.
Example fix
// before (view offers Remove for every run) <%= link_to 'Remove', remove_admin_import_jira_import_run_path(run) %> // after (only offer Remove when the run is not running) <%= link_to 'Remove', remove_admin_import_jira_import_run_path(run) unless run.status_running? %>
Defensive patterns
Strategy: validation
Validate before calling
# before invoking remove raise ArgumentError, 'import still running' if jira_import.status_running?
Try / catch
begin jira_import.destroy! rescue StandardError => e flash[:error] = e.message if e.message == I18n.t(:'admin.jira.run.remove_error') end
Prevention
- Hide/disable the Remove button for runs whose status is running; offer Revert/Finalize instead.
- Ensure finished/failed jobs always transition JiraImport status (side-effect finalizers) so rows never stick in running.
- Monitor GoodJob for errored JiraImportProjectsJob executions before attempting cleanup.
When it happens
Trigger: Clicking 'Remove' on an import run row in Admin → Jira import while the run's status column is 'running'; i.e. the Jira import job is currently executing (or the status was never finalized) when the DELETE/remove action posts to admin/import/jira/import_runs.
Common situations: The GoodJob/worker process crashed or the job hung, so the JiraImport row is stuck in 'running' forever; an admin tries to clean up a stale import; double-submitting the remove button while a long import is in flight.
Related errors
- Invalid API token. Please check your credentials in the conf
- Jira API returned a 401 error. Your authentication token may
- Jira API returned a 429 error. It means token owner has been
- Jira API returned error status %{status}
- You are trying to import a project with an already used iden
AI-assisted analysis of opf/openproject@d9742c43f3 (2026-08-21).
Data as JSON: /api/errors/7b666e0e07699976.
Report an issue: GitHub.