Commit c084ac4b authored by Tetiana Chupryna's avatar Tetiana Chupryna

Merge branch 'pl-error-tracking-length-validation' into 'master'

Add length validations for error tracking errors and events

See merge request gitlab-org/gitlab!74012
parents 45f4b2ce 80bd4134
...@@ -18,9 +18,10 @@ class ErrorTracking::Error < ApplicationRecord ...@@ -18,9 +18,10 @@ class ErrorTracking::Error < ApplicationRecord
scope :for_status, -> (status) { where(status: status) } scope :for_status, -> (status) { where(status: status) }
validates :project, presence: true validates :project, presence: true
validates :name, presence: true validates :name, presence: true, length: { maximum: 255 }
validates :description, presence: true validates :description, presence: true, length: { maximum: 1024 }
validates :actor, presence: true validates :actor, presence: true, length: { maximum: 255 }
validates :platform, length: { maximum: 255 }
validates :status, presence: true validates :status, presence: true
enum status: { enum status: {
......
...@@ -6,7 +6,9 @@ class ErrorTracking::ErrorEvent < ApplicationRecord ...@@ -6,7 +6,9 @@ class ErrorTracking::ErrorEvent < ApplicationRecord
validates :payload, json_schema: { filename: 'error_tracking_event_payload' } validates :payload, json_schema: { filename: 'error_tracking_event_payload' }
validates :error, presence: true validates :error, presence: true
validates :description, presence: true validates :description, presence: true, length: { maximum: 1024 }
validates :level, length: { maximum: 255 }
validates :environment, length: { maximum: 255 }
validates :occurred_at, presence: true validates :occurred_at, presence: true
def stacktrace def stacktrace
......
...@@ -11,7 +11,10 @@ RSpec.describe ErrorTracking::ErrorEvent, type: :model do ...@@ -11,7 +11,10 @@ RSpec.describe ErrorTracking::ErrorEvent, type: :model do
describe 'validations' do describe 'validations' do
it { is_expected.to validate_presence_of(:description) } it { is_expected.to validate_presence_of(:description) }
it { is_expected.to validate_length_of(:description).is_at_most(1024) }
it { is_expected.to validate_presence_of(:occurred_at) } it { is_expected.to validate_presence_of(:occurred_at) }
it { is_expected.to validate_length_of(:level).is_at_most(255) }
it { is_expected.to validate_length_of(:environment).is_at_most(255) }
end end
describe '#stacktrace' do describe '#stacktrace' do
......
...@@ -12,8 +12,12 @@ RSpec.describe ErrorTracking::Error, type: :model do ...@@ -12,8 +12,12 @@ RSpec.describe ErrorTracking::Error, type: :model do
describe 'validations' do describe 'validations' do
it { is_expected.to validate_presence_of(:name) } it { is_expected.to validate_presence_of(:name) }
it { is_expected.to validate_length_of(:name).is_at_most(255) }
it { is_expected.to validate_presence_of(:description) } it { is_expected.to validate_presence_of(:description) }
it { is_expected.to validate_length_of(:description).is_at_most(1024) }
it { is_expected.to validate_presence_of(:actor) } it { is_expected.to validate_presence_of(:actor) }
it { is_expected.to validate_length_of(:actor).is_at_most(255) }
it { is_expected.to validate_length_of(:platform).is_at_most(255) }
end end
describe '.report_error' do describe '.report_error' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment