Details
-
Type:
Improvement
-
Status: Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 6.5.0.1
-
Component/s: Module - Workflow
-
Labels:
-
Story Points:1
-
Sprint:2020.05 - IDM, 2020.06 - IDM, 2020.07 - IDM
-
Support Ticket IDs:
-
Epic Link:
Description
Although typical input validation relies on JS validation to validate input on the form, there are some cases when customers are invoking workflows via REST. In this case, the calling application should validate input data, however it may also be required that the workflow scripts do simple validation and throw an exception which would be translated to a HTTP response.
Currently it seems that exceptions thrown in workflow scripts generate a HTTP 500 in every case. For example trying to throw a the following ResourceException from a groovy workflow script (as per https://backstage.forgerock.com/docs/idm/6.5/integrators-guide/#custom-script-errors):
import org.forgerock.json.resource.ResourceException import org.forgerock.json.JsonValue throw new ResourceException(400, "My custom error message").setDetail(new JsonValue(["var": "parameter1","complexDetailObject" : ["detail1","detail2"]]))
Results in a HTTP 500, with the following response:
{ "code":500, "reason":"Internal Server Error", "message":"problem evaluating script: javax.script.ScriptException: org.forgerock.json.resource.ResourceException: My custom error message" }
The ability to throw ResourceException and have them returned to the calling application would allow effective error handling for REST based services.