Handle Exception for Required Fields in Create a new hook script API

XMLWordPrintable

    • Type: Suggestion
    • Resolution: Unresolved
    • None
    • Component/s: API - REST
    • None
    • 1

      While invoking the Create a new hook script API, if any of the required fields are missed, we get the below exception in the atlassian-bitbucket.log on the server:

      2025-11-20 14:42:17,106 ERROR [http-nio-7990-exec-7] admin @MXMWKHx882x605x0 0:0:0:0:0:0:0:1 "POST /rest/api/latest/hook-scripts HTTP/1.1" c.a.b.i.r.e.UnhandledExceptionMapper Unhandled exception while processing REST request: "POST /rest/api/latest/hook-scripts HTTP/1.1"
      java.lang.NullPointerException: null
      	at java.base/java.util.Objects.requireNonNull(Objects.java:233)
      	at com.atlassian.stash.internal.rest.hook.script.HookScriptResource.createHookScript(HookScriptResource.java:108)
      	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
      	at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory.lambda$static$0(ResourceMethodInvocationHandlerFactory.java:52)
      	at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:146)
      	at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:189)
      	at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:176)
      	at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:93)
      	at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:478)
      	at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:400)
      	at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:81)
      	at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:256)
      

      Instead, can we have a meaningful message returned like we get if we use a HTTP Access token instead of a sys admin password:

      pwaje@YDL91NPC6R ~ %    curl  --request POST --user "admin:BBDC-MjE1OTgwMTg1MTk1OsBRFC0zzpZPHL+Fzvzk2jrqy0sE" --header "X-Atlassian-Token:no-check"  --form "name=rejectAll new" --form "description=Prüft den Puppet Code" --form "content=@rejectAll.sh" "http://localhost:7990/bitbucket/rest/api/latest/hook-scripts" -F "type=PRE"
      {"errors":[{"message":"You are not permitted to access this resource","exceptionName":"com.atlassian.bitbucket.AuthorisationException"}]}%                                                    pwaje@YDL91NPC6R ~ % 
      

              Assignee:
              Unassigned
              Reporter:
              Priyata Waje
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated: