Draft: Add error handling for ForkService
What does this MR do and why?
Contributes to #346563 (closed)
Problem
- The error handling for ForkService is incomplete
- ForkService does not use ServiceResponse object
Solution
- Separate fork linking method from
#execute
- Use ServiceResponse to return execution results
- Handle the case when the fork is linked to itself
Next step
Migrate execute
to ServiceResponse
model and merge these two methods back if necessary. Follow-up issue: #378472 (closed)
How to test 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.
# Before
curl -X POST -H "PRIVATE-TOKEN: TOKEN" "http://127.0.0.1:3000/api/v4/projects/1/fork/1"
{"message":"500 Internal Server Error"}
# After
curl -X POST -H "PRIVATE-TOKEN: TOKEN" "http://127.0.0.1:3000/api/v4/projects/1/fork/1"
{"message":"Target project cannot be equal to source project"}
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Edited by Vasilii Iakliushin