[Bug]: Deleting a GitHub app from sources breaks resources that used the associated private key
Description
Hi,
I migrated from private repository via GitHub app to private repository via deploy keys because I have private submodules that I could not get to deploy when using GitHub app.
When doing so, I reused the private key created when creating the GitHub app that is associated with it. I did not realize that they were linked. What happened is after doing my configs migrations is that I deleted the GitHub app source, which also deleted the associated private key.
This results in a 500 error when entering resources that use this deleted private key.
This is an edge case but that broke my setup as I was not aware the private key would be deleted as well. I had to restore a backup.
I believe you need to add a check when deleting a GitHub app that verifies that there are no resources that use the associated deleted private key.
Minimal Reproduction (if possible, example repository)
- Create GitHub app source
- Create a private Github resource with deploy key that uses the private key created with the GitHub app
- Delete the GitHub app -> this will automatically delete the associated private key
- Private Github resource with deploy key is broken HTTP 500
Exception or Error
Error 500
Attempt to read property "name ", ....
Version
v4.0.0-beta.266
Here is a repro video that shows the full steps that got me into breaking the setup.
https://github.com/coollabsio/coolify/assets/26366184/22ce2b28-6642-4b0b-9cc5-d694fe6193db
Oh, thanks for catching that!
In the next version, you will only be able to delete a GitHub App if you have deleted all associated resources + fix for that http 500.