In the API I'm working on there's a bulk delete operation which accepts an array of IDs:
["1000", ..., "2000"]
I was free to implement the delete operation as I saw fit, so I decided to make the whole thing transactional: that is, if a single ID is invalid, the entire request fails. I'll call this the strict mode.
try{
savepoint = conn.setSavepoint();
for(id : IDs)
if( !deleteItem(id) ){
conn.rollback(savepoint);
sendHttp400AndBeDoneWithIt();
return;
}
conn.commit();
}
The alternative (implemented elsewhere in our software suite) is to do what we can in the backend, and report failures in an array. That part of the software deals with fewer requests so the response doesn't end up being a gigantic array... in theory.
A recent bug occurring in a resource-poor server made me look at the code again, and now I'm questioning my original decision - but this time I'm motivated more by business needs rather than best practices. If, for example, I fail the entire request, the user will have to try again whereas if a number of items get deleted, the user can finish the action and then ask an administrator to do the rest (while I work on fixing the bug!). This would be the permissive mode.
I tried looking online for some guidance on the matter but I've come up empty handed. So I come to you: What is most expected by bulk operations of this nature? Should I stick with strict more, or should I be more permissive?