Skip to content

Draft: Add error handling for ForkService

Vasilii Iakliushin requested to merge 346563_fix_500_for_fork_service into master

What does this MR do and why?

Contributes to #346563 (closed)

Problem

  1. The error handling for ForkService is incomplete
  2. 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

  1. curl -X POST -H 'PRIVATE-TOKEN: <YOUR-TOKEN>' 'http://127.0.0.1:3000/api/v4/projects/1/fork/1'
  2. 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.

Edited by Vasilii Iakliushin

Merge request reports