Commit b61cda1c authored by Stan Hu's avatar Stan Hu

Fix feature flag check failing when database is empty

As seen in QA pipelines and discussed in
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/42229, the Grape
API initialization would fail if the database were empty. We now check
the existence of the `features` table to prevent this from happening.

This still does not allow us to change the feature flag dynamically, but
it unblocks the test failures.
parent 5ec707ed
...@@ -118,7 +118,7 @@ module API ...@@ -118,7 +118,7 @@ module API
# There is a small chance some users depend on the old behavior. # There is a small chance some users depend on the old behavior.
# We this change under a feature flag to see if affects GitLab.com users. # We this change under a feature flag to see if affects GitLab.com users.
if Feature.enabled?(:api_json_content_type) if Gitlab::Database.cached_table_exists?('features') && Feature.enabled?(:api_json_content_type)
content_type :json, 'application/json' content_type :json, 'application/json'
else else
content_type :txt, 'text/plain' content_type :txt, 'text/plain'
......
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