{"record":{"id":"7b666e0e07699976","repo":"opf/openproject","slug":"a-jira-import-run-cannot-be-removed-while-it-is-ru","errorCode":null,"errorMessage":"A Jira import run cannot be removed while it is running","messagePattern":"A Jira import run cannot be removed while it is running","errorType":"exception","errorClass":"StandardError","httpStatus":null,"severity":"error","filePath":"app/controllers/admin/import/jira/import_runs_controller.rb","lineNumber":84,"sourceCode":"      end\n    rescue StandardError => e\n      handle_error(e)\n    end\n\n    def import_modal\n      respond_with_dialog Admin::Import::Jira::ImportRuns::ImportConfirmDialogComponent.new(jira_import: @jira_import)\n    end\n\n    def revert_modal\n      respond_with_dialog Admin::Import::Jira::ImportRuns::RevertConfirmDialogComponent.new(jira_import: @jira_import)\n    end\n\n    def finalize_modal\n      respond_with_dialog Admin::Import::Jira::ImportRuns::FinalizeConfirmDialogComponent.new(jira_import: @jira_import)\n    end\n\n    def remove\n      raise StandardError.new(I18n.t(:\"admin.jira.run.remove_error\")) if @jira_import.status_running?\n\n      @jira_import.destroy!\n      redirect_to admin_import_jira_path(@jira), status: :see_other\n    end\n\n    def history\n      @history = @jira_import.history\n    end\n\n    private\n\n    def change_step(step)\n      return if step.blank?\n\n      method_name = VALID_STEPS.detect { |i| i == step.to_sym }\n      raise ArgumentError, \"Invalid step: #{step}\" unless method_name\n\n      send(method_name)","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/opf/openproject/blob/d9742c43f3424c34b63550f8c03f201fe5c3040c/app/controllers/admin/import/jira/import_runs_controller.rb#L66-L102","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before (view offers Remove for every run)\n<%= link_to 'Remove', remove_admin_import_jira_import_run_path(run) %>\n\n// after (only offer Remove when the run is not running)\n<%= link_to 'Remove', remove_admin_import_jira_import_run_path(run) unless run.status_running? %>","handlingStrategy":"validation","validationCode":"# before invoking remove\nraise ArgumentError, 'import still running' if jira_import.status_running?","typeGuard":null,"tryCatchPattern":"begin\n  jira_import.destroy!\nrescue StandardError => e\n  flash[:error] = e.message if e.message == I18n.t(:'admin.jira.run.remove_error')\nend","preventionTips":["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."],"tags":["jira-import","admin","state-transition","background-job","goodjob"],"backgroundTag":"invalid-state-transition","analyzedSha":"d9742c43f3424c34b63550f8c03f201fe5c3040c","analyzedAt":"2026-08-21T14:40:06.829Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}