Commit 7d680ceb authored by Dylan Griffith's avatar Dylan Griffith

Restore a rescue in PreventCrossDatabaseModification

This was removed in 5ec78473 and I had
to add it back because we can't raise exceptions in development for all
cross-modifications because so far we've only ensured the allowlist is
correct for specs files and don't have inline allows for all the known
violations. I was able to see a failure by creating a pipeline with
`environment` and it failed with 500. Since we want to be able to enable
the feature flag and env var by default we don't want to break
everyone's local development experience.
parent 44cbfb60
......@@ -91,9 +91,20 @@ module Gitlab
raise CrossDatabaseModificationAcrossUnsupportedTablesError, message
end
rescue CrossDatabaseModificationAcrossUnsupportedTablesError => e
::Gitlab::ErrorTracking.track_exception(e, { gitlab_schemas: schemas, tables: all_tables, query: parsed.sql })
raise if raise_exception?
end
# rubocop:enable Metrics/AbcSize
# We only raise in tests for now otherwise some features will be broken
# in development. For now we've mostly only added allowlist based on
# spec names. Until we have allowed all the violations inline we don't
# want to raise in development.
def self.raise_exception?
Rails.env.test?
end
# We ignore execution in the #create method from FactoryBot
# because it is not representative of real code we run in
# production. There are far too many false positives caused
......
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