Admin batched background migrations and operations APIs return 500 for a database that isn't configured

The admin batched background migrations and background operations APIs accept every name in Gitlab::Database.all_database_names as their database parameter, including databases that aren't configured. For an unconfigured database, such as geo or embedding, every endpoint returns a 500. mr_diff joins that list when !266521 merges.

The endpoints should return a 404, like /admin/migrations does (Database '<name>' is not configured).

Details
  • base_model is nil when the database isn't configured (lib/api/admin/batched_background_migrations.rb:166), and every endpoint calls base_model.connection (lines 41, 71, 106 and 146), which raises NoMethodError.
  • lib/api/admin/batched_background_operations.rb has the same base_model helper, and its endpoints fail the same way.
  • lib/api/admin/migrations.rb:104 already returns a 404 for the same input.
Edited by 🤖 GitLab Bot 🤖