Resolve "Error 500 when trying to destroy OAuth application entry in admin area"
What does this MR do?
Fix for #23746 (closed)
Why?
A missing on_delete: :cascade
constraint on the oauth_openid_requests
table is currently causing trouble when deleting applications from the Admin area.
This is because
-
On deleting an application, all of its related
access_grants
records are deleted bydelete_all
callback (https://github.com/doorkeeper-gem/doorkeeper/blob/v4.3.1/lib/doorkeeper/orm/active_record/application.rb#L8) -
Since a
delete_all
callback is executed, thedependent: :delete
callback on it's correspondingoauth_openid_request
record onaccess_grants
do not run. (https://github.com/doorkeeper-gem/doorkeeper-openid_connect/blob/v1.5.0/lib/doorkeeper/openid_connect/orm/active_record/access_grant.rb#L9) -
Since this callback does not run and
access_grant
records are forced to be deleted, the existingforeign_key
constraint on
oauth_openid_request
gives error like:
Fix
By adding the foreign_key constraint on_delete: :cascade
, we can solve this problem.
Screenshots
Does this MR meet the acceptance criteria?
Conformity
-
Changelog entry -
Documentation (if required) -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
-
Label as security and @ mention @gitlab-com/gl-security/appsec
-
The MR includes necessary changes to maintain consistency between UI, API, email, or other methods -
Security reports checked/validated by a reviewer from the AppSec team