Class: RailsErrorDashboard::CreateIssueJob

Inherits:
ApplicationJob
  • Object
show all
Defined in:
app/jobs/rails_error_dashboard/create_issue_job.rb

Overview

Background job for creating issues on GitHub/GitLab/Codeberg.

Used by auto-create (triggered from plugin hooks) and can be called directly for deferred issue creation.

Retry strategy: 3 attempts with exponential backoff. Circuit breaker: skips if >5 failures in the last 10 minutes (tracked via class-level counter, reset on success).

Constant Summary collapse

CIRCUIT_BREAKER_THRESHOLD =
5
CIRCUIT_BREAKER_WINDOW =

10 minutes

600
@@recent_failures =

Simple circuit breaker — class-level failure tracking

[]

Instance Method Summary collapse

Instance Method Details

#perform(error_log_id, dashboard_url: nil) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'app/jobs/rails_error_dashboard/create_issue_job.rb', line 23

def perform(error_log_id, dashboard_url: nil)
  if circuit_open?
    Rails.logger.warn("[RailsErrorDashboard] CreateIssueJob circuit breaker open — skipping")
    return
  end

  result = Commands::CreateIssue.call(error_log_id, dashboard_url: dashboard_url)

  if result[:success]
    record_success
    Rails.logger.info("[RailsErrorDashboard] Issue created for error #{error_log_id}: #{result[:issue_url]}")
  else
    record_failure
    Rails.logger.error("[RailsErrorDashboard] Failed to create issue for error #{error_log_id}: #{result[:error]}")
    # Don't retry on "already has a linked issue" or "not configured"
    return if result[:error]&.include?("already has") || result[:error]&.include?("not configured")
    raise "Issue creation failed: #{result[:error]}" # triggers retry
  end
rescue ActiveRecord::RecordNotFound
  # Error was deleted — discard silently
rescue => e
  record_failure
  raise # re-raise for retry
end