Uploaded image for project: 'OpenIDM'
  1. OpenIDM
  2. OPENIDM-4919

Script eval action doesn't handle ResourceExceptions thrown by scripts

    Details

      Description

      As originally noted here: https://bugster.forgerock.org/jira/browse/SCRIPT-10?focusedCommentId=64143&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-64143

      Calls to the script service which throw an exception are not handled properly:

      curl --data '{ "type": "groovy", "source": " import org.forgerock.json.resource.ResourceException; throw new ResourceException(404, \"It aint there\").setDetail(new org.forgerock.json.JsonValue([a:1]))" }' -u openidm-admin:openidm-admin -k -X POST -H "Content-type: application/json" https://localhost:8443/openidm/script?_action=eval
      

      Produces this:

      {"code":500,"reason":"Internal Server Error","message":"It aint there"}
      

      Note the lack of the detail and the wrong code. Similarly, JS doesn't work properly (see link for details)

      Those same scripts work fine when executed as part of a custom endpoint, defined (for example) like so:

      {
          "type" : "groovy",
          "source" : " import org.forgerock.json.resource.ResourceException; import org.forgerock.json.JsonValue; throw new ResourceException(404, \"It ain't there\").setDetail(new JsonValue([\"var\": \"blah\", \"complexDetailObject\" : [\"detail1\",\"detail2\"]]))"
      }
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                brmiller Brendan Miller
                Reporter:
                jake.feasel Jake Feasel
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: