Class: RailsErrorDashboard::WebhooksController

Inherits:
ActionController::Base
  • Object
show all
Defined in:
app/controllers/rails_error_dashboard/webhooks_controller.rb

Overview

Receives webhooks from GitHub/GitLab/Codeberg for two-way issue sync.

When an issue is closed/reopened on the platform, the corresponding error in the dashboard is resolved/reopened to match.

Security: HMAC signature verification for each provider.

  • GitHub: X-Hub-Signature-256 (HMAC-SHA256)

  • GitLab: X-Gitlab-Token (shared secret)

  • Codeberg: X-Gitea-Signature (HMAC-SHA256)

Instance Method Summary collapse

Instance Method Details

#receiveObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'app/controllers/rails_error_dashboard/webhooks_controller.rb', line 19

def receive
  provider = params[:provider]
  payload = parse_payload

  return head :ok unless payload

  case provider
  when "github"
    handle_github(payload)
  when "gitlab"
    handle_gitlab(payload)
  when "codeberg"
    handle_codeberg(payload)
  else
    head :not_found
    return
  end

  head :ok
rescue => e
  Rails.logger.error("[RailsErrorDashboard] Webhook error: #{e.class}: #{e.message}")
  head :ok # Always return 200 to prevent webhook retries on our errors
end