API response for adding a note returns HTTP 400 for command only notes
Summary
If you use the HTTP RESTful API to add a note that only applies slash-commands, the API controller correctly applies the commands, but then responds incorrectly with HTTP 400
. The response should be HTTP 200
.
Steps to reproduce
Use the HTTP API to add a note that only includes a slash command (eg. /assign @alexkalderimis
).
Example Project
This works on any MR. An example response is included below:
POST https://gitlab.com/api/v4/projects/278964/merge_requests/19568/notes
400 {message: 400 (Bad request) "Note {:note=>["can't be blank"]}" not given}
I would also mention that the message is less than ideal, since it is neither structured data, nor natural language.
What is the current bug behavior?
Successfully applied notes return HTTP 400
What is the expected correct behavior?
If a note includes only slash commands, this should be considered a success, and the response should be HTTP 200
, perhaps with an indication of what commands were applied.
Output of checks
This bug happens on GitLab.com
Possible fixes
Instead of checking the note content itself, check the input data.
This appears to be located at: [[/lib/api/notes.rb?L82]], where instead of a validity check, we should be also checking to see if any commands were applied.