Skip to content

Return error reasons from DraftNotes::PublishService#execute and consume in API

Problem to solve

REST API consumers of DraftNotes::PublishService#execute return HTTP 500 (internal server error!) on user errors such as authorization failures and validation errors. This is because #execute returns a bare #error without a :reason attached.

Proposal

Attach a :reason to the different errors and return the appropriate HTTP status for the given reason.

Background

The following discussion from !208487 (merged) should be addressed:

  • @ngala started a discussion: (+2 comments)

    Question: Should it be 422 instead of 500?

Edited by 🤖 GitLab Bot 🤖