parse-server icon indicating copy to clipboard operation
parse-server copied to clipboard

log the field that was the added during validatingPermission

Open RahulLanjewar93 opened this issue 1 year ago • 5 comments

New Feature / Enhancement Checklist

Current Limitation

Currently, when there's a newly added field to an object, we validate for permission if it can be added

if (newKeys.length > 0) {
      // adds a marker that new field is being adding during update
      runOptions.addsField = true;
      const action = runOptions.action;
      return schema.validatePermission(className, aclGroup, 'addField', action);
 }

validatePermission can throw an error depending on whether the field can be added or not. Actual Error :- ParseError: Permission denied for action addField on class _User. I think would be better to log the newly added field if in case validatePermission throws error

Feature / Enhancement Description

Log the newly added field if the validation fields, as it provides better information on what went wrong. Expected Error :- ParseError: Permission denied for action addField on class -User.

RahulLanjewar93 avatar Jun 26 '23 06:06 RahulLanjewar93

Thanks for opening this issue!

  • 🎉 We are excited about your ideas for improvement!

@mtrezza any suggestions here? I can pick it up if required

RahulLanjewar93 avatar Sep 18 '23 06:09 RahulLanjewar93

Sure, if I understand that feature request correctly, the field name should be added to an existing error log.

mtrezza avatar Sep 18 '23 14:09 mtrezza

Sure, if I understand that feature request correctly, the field name should be added to an existing error log.

Yes that's correct

RahulLanjewar93 avatar Sep 19 '23 16:09 RahulLanjewar93

I am thinking about what would be the best way to do it, validatePermisison is a generic function that validates and throws error. one way would be to add adittional data to the static method validatePermission. other way would be to add a try catch handler on the top, mutate the error message and rethrow. @mtrezza what do you think

RahulLanjewar93 avatar Sep 25 '23 22:09 RahulLanjewar93