rails_error_dashboard 0.11.7 → 0.11.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f55384ffa88ee1326e9575a6432eb392df3995395b8b4e821b5ec2576d34ab53
4
- data.tar.gz: a4166ab78f73a536986bb7b0c68c6ee95975db9769a611a69646900ca0d45d95
3
+ metadata.gz: f07dcfe9569e107c4f8b3bee4f15e106c4b537690d9bf002af887e832d9e0a9b
4
+ data.tar.gz: 5defe92b8156a8564a6a1286d2e5199b450b2f6ca894bcafd65586fe3723a7e0
5
5
  SHA512:
6
- metadata.gz: 218881302d12e08887dc80dfcebd3d32b010d931dbec325c8f88317300f6c5006e88edab2d01e94d4ba8a12bc01daa0d19b94c9a787515b611ae980860ab4e0c
7
- data.tar.gz: 7d7ddd33b49891aa68ad8fa206465b4aa7f2f3a6ae1f2ae5e354a3f19f8b8ee6a68776a2662a14bbaedfb4029ccc15c5c479c0e2cd10d26869b2aff75021df45
6
+ metadata.gz: 0fe0f1b0894c8c1c797e341b2e00d2120871dca2bcc2800527f69a99831cd700005f21245b6a3a0fef86f0c7466ec0e1f588e21cb503c8c3621f9d203c79ce4c
7
+ data.tar.gz: ba3e9269169d059eeab3cf3f469294ac520a9144558199c05e0dc0b5262b7bbbd0ec8a28896f15fd26ee5a605ed74f5707eae7e38a354160341b676cbe9d7d58
@@ -6,8 +6,8 @@ module RailsErrorDashboard
6
6
  include Concerns::LocalizedJob
7
7
 
8
8
  # CRITICAL: Ensure job failures don't break the app or spam error logs
9
- # Retry failed jobs with exponential backoff, but limit attempts
10
- retry_on StandardError, wait: :exponentially_longer, attempts: 3
9
+ # Retry failed jobs with polynomial backoff, but limit attempts
10
+ retry_on StandardError, wait: :polynomially_longer, attempts: 3
11
11
 
12
12
  # Global exception handling for all dashboard jobs
13
13
  rescue_from StandardError do |exception|
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+
3
+ # The dashboard's PostgreSQL full-text search (Queries::ErrorsList#filter_by_search)
4
+ # matches against message, backtrace and error_type together:
5
+ #
6
+ # to_tsvector('english', COALESCE(message, '') || ' ' || COALESCE(backtrace, '') || ' ' || COALESCE(error_type, ''))
7
+ #
8
+ # PostgreSQL uses an expression index only when the query's expression is
9
+ # identical to the index's, so of the two GIN indexes defined over time only
10
+ # one can serve that search:
11
+ #
12
+ # index_error_logs_on_message_gin to_tsvector('english', message) never used by any query
13
+ # index_error_logs_on_searchable_text the expression above the one the search needs
14
+ #
15
+ # Which of them a host has depends on how it was installed. Hosts that ran the
16
+ # incremental chain got both; hosts installed from the squashed first migration
17
+ # got neither (the later index migrations skip themselves once the squash's
18
+ # composite indexes exist), and 0.11.7 then added only the message-only one.
19
+ #
20
+ # This converges every install on index_error_logs_on_searchable_text alone.
21
+ # No-op on other adapters.
22
+ class ReplaceMessageGinWithSearchableTextIndex < ActiveRecord::Migration[7.0]
23
+ TABLE = :rails_error_dashboard_error_logs
24
+
25
+ def up
26
+ return unless postgresql?
27
+ return unless table_exists?(TABLE)
28
+
29
+ execute <<~SQL
30
+ CREATE INDEX IF NOT EXISTS index_error_logs_on_searchable_text
31
+ ON rails_error_dashboard_error_logs
32
+ USING gin(to_tsvector('english',
33
+ COALESCE(message, '') || ' ' || COALESCE(backtrace, '') || ' ' || COALESCE(error_type, '')
34
+ ))
35
+ SQL
36
+
37
+ execute "DROP INDEX IF EXISTS index_error_logs_on_message_gin"
38
+ end
39
+
40
+ def down
41
+ return unless postgresql?
42
+
43
+ # There is no single state to return to: before this migration a host had
44
+ # either both indexes or only the message-only one, depending on its
45
+ # install path. Dropping searchable_text here would take away, on
46
+ # incremental-chain hosts, an index they had before, and nothing needs
47
+ # message_gin back. Earlier gem versions run unchanged against the
48
+ # converged schema.
49
+ raise ActiveRecord::IrreversibleMigration,
50
+ "this migration converges two index layouts (see its header); the previous layout is not recoverable"
51
+ end
52
+
53
+ private
54
+
55
+ def postgresql?
56
+ connection.adapter_name.downcase == "postgresql"
57
+ end
58
+ end
@@ -420,9 +420,10 @@ RailsErrorDashboard.configure do |config|
420
420
  # config.crash_capture_path = "/tmp/my_app_crashes"
421
421
 
422
422
  <% end -%>
423
- # Repository settings (auto-detected from git remote, optional override)
424
- # config.repository_url = ENV["REPOSITORY_URL"] # e.g., "https://github.com/user/repo"
425
- # config.repository_branch = ENV.fetch("REPOSITORY_BRANCH", "main") # Default branch
423
+ # "View Source" links need config.git_repository_url (set under Enhanced
424
+ # metrics below); nothing is auto-detected from the git remote.
425
+ # Which ref the links point at:
426
+ # config.git_branch_strategy = :commit_sha # :commit_sha (default), :current_branch, or :main
426
427
 
427
428
  # ============================================================================
428
429
  # INTERNAL LOGGING (Silent by Default)
@@ -15,6 +15,11 @@ module RailsErrorDashboard
15
15
  # generator.generate_link
16
16
  # # => "https://github.com/user/repo/blob/abc123def456/app/models/user.rb#L42"
17
17
  class GithubLinkGenerator
18
+ # The generated link is an href handed to every dashboard user, so only
19
+ # web URLs are ever linked. javascript:, data: and scp-style git@ forms
20
+ # produce no link even though the value comes from deployer configuration.
21
+ ALLOWED_SCHEMES = %w[http https].freeze
22
+
18
23
  attr_reader :repository_url, :file_path, :line_number, :commit_sha, :branch, :error
19
24
 
20
25
  # Initialize a new link generator
@@ -42,6 +47,11 @@ module RailsErrorDashboard
42
47
  # Normalize repository URL
43
48
  normalized_repo = normalize_repository_url
44
49
 
50
+ unless repository_host
51
+ @error = "Unsupported repository URL scheme: only http and https URLs are linked"
52
+ return nil
53
+ end
54
+
45
55
  # Determine reference (commit SHA or branch)
46
56
  reference = determine_reference
47
57
 
@@ -77,16 +87,33 @@ module RailsErrorDashboard
77
87
  url
78
88
  end
79
89
 
80
- # Detect repository type from URL
90
+ # Host of the repository URL, downcased, or nil when the value is not an
91
+ # http(s) URL with a host.
92
+ #
93
+ # @return [String, nil]
94
+ def repository_host
95
+ uri = URI.parse(normalize_repository_url)
96
+ return nil unless ALLOWED_SCHEMES.include?(uri.scheme.to_s.downcase) && uri.host.present?
97
+
98
+ uri.host.downcase
99
+ rescue URI::InvalidURIError
100
+ nil
101
+ end
102
+
103
+ # Detect repository type from the URL's host. Only the host is consulted,
104
+ # so "github.com" appearing in a path, query string or userinfo does not
105
+ # count. Self-hosted GitLab, Bitbucket, Gitea and Forgejo instances are
106
+ # recognised by their conventional subdomain ("gitlab.example.com").
81
107
  #
82
108
  # @return [Symbol] :github, :gitlab, :bitbucket, :codeberg, or :unknown
83
109
  def detect_repository_type
84
- normalized = normalize_repository_url.downcase
110
+ host = repository_host
111
+ return :unknown unless host
85
112
 
86
- return :github if normalized.include?("github.com")
87
- return :gitlab if normalized.include?("gitlab.com") || normalized.include?("gitlab.")
88
- return :bitbucket if normalized.include?("bitbucket.org") || normalized.include?("bitbucket.")
89
- return :codeberg if normalized.include?("codeberg.org") || normalized.include?("gitea.") || normalized.include?("forgejo.")
113
+ return :github if host == "github.com" || host.end_with?(".github.com")
114
+ return :gitlab if host == "gitlab.com" || host.include?("gitlab.")
115
+ return :bitbucket if host == "bitbucket.org" || host.include?("bitbucket.")
116
+ return :codeberg if host == "codeberg.org" || host.include?("gitea.") || host.include?("forgejo.")
90
117
 
91
118
  :unknown
92
119
  end
@@ -1,3 +1,3 @@
1
1
  module RailsErrorDashboard
2
- VERSION = "0.11.7"
2
+ VERSION = "0.11.9"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_error_dashboard
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.7
4
+ version: 0.11.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anjan Jagirdar
@@ -410,6 +410,7 @@ files:
410
410
  - db/migrate/20260826000001_add_environment_to_error_logs.rb
411
411
  - db/migrate/20260908000001_add_release_to_error_occurrences.rb
412
412
  - db/migrate/20260908220001_add_missing_postgresql_indexes_to_error_logs.rb
413
+ - db/migrate/20260909000001_replace_message_gin_with_searchable_text_index.rb
413
414
  - lib/generators/rails_error_dashboard/install/install_generator.rb
414
415
  - lib/generators/rails_error_dashboard/install/templates/README
415
416
  - lib/generators/rails_error_dashboard/install/templates/initializer.rb
@@ -578,7 +579,7 @@ metadata:
578
579
  funding_uri: https://github.com/sponsors/AnjanJ
579
580
  post_install_message: |
580
581
  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
581
- RED (Rails Error Dashboard) v0.11.7
582
+ RED (Rails Error Dashboard) v0.11.9
582
583
  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
583
584
 
584
585
  First install: