Fix the error when the fork is linked to itself
What does this MR do and why?
Contributes to #346563 (closed)
Problem
There is no validation for the case when the project is linked to itself. It leads to 500 error.
Solution
Check this case and respond with an error.
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
Before | After |
---|---|
{"message":"500 Internal Server Error"}% |
{"message":"Target project cannot be equal to source project"}% |
How to set up and validate locally
curl -X POST -H 'PRIVATE-TOKEN: <YOUR-TOKEN>' 'http://127.0.0.1:3000/api/v4/projects/1/fork/1'
- You should see 400 error instead of 500 error.
Edited by Vasilii Iakliushin