Fix external status checks error responses
Context
The service error responses for external status checks actions like create, update and destroy are missing an error in the payload when AllBranchesRules or AllProtectedBranches are detected as branch rules.
Since the GraphQL mutations for external status check call these services and expect an error in the payload, we are returning an empty array in the errors object instead of the corresponding error message.
In all of these services, we set something like the following:
def execute_on_all_branches_rule
ServiceResponse.error(message: 'All branch rules cannot configure external status checks')
end
def execute_on_all_protected_branches_rule
ServiceResponse.error(message: 'All protected branch rules cannot configure external status checks')
end
We should change this by something like the following:
def execute_on_all_branches_rule
ServiceResponse.error(
message: 'All branch rules cannot configure external status checks',
payload: { errors: ['All branch rules not allowed'] },
reason: :unprocessable_entity
)
end
def execute_on_all_protected_branches_rule
ServiceResponse.error(
message: 'All protected branch rules cannot configure external status checks',
payload: { errors: ['All protected branches not allowed'] },
reason: :unprocessable_entity
)
end
Edited by Javiera Tapia