Bug in notes creation response
There is a bug introduced in b96ca8d9
# Allow consumers to detect problems applying commands
note.errors.add(:commands, _('Commands did not apply')) unless message.present?
This is incorrect because message
here actually contains both success and error messages. Meaning, if message
contained an error, note.errors[:commands]
won't be set and then in this block of code:
if note.errors.keys == [:commands_only]
status 202
present note, with: Entities::NoteCommands
elsif note.valid?
present note, with: Entities.const_get(note.class.name, false)
else
note.errors.delete(:commands_only) if note.errors.has_key?(:commands)
bad_request!("Note #{note.errors.messages}")
end
We'd always get a 202
even if the quick actions had some errors.
I think we need to clean up how we pass these messages in the response because passing success messages in a model's error
hash is confusing and can lead to wrong assumptions like this. This can be done with #213679 where we want to separate the success and error messages in the frontend.