Uploaded image for project: 'Bitbucket Data Center'
  1. Bitbucket Data Center
  2. BSERV-20264

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

XMLWordPrintable

    • Icon: Suggestion Suggestion
    • Resolution: Unresolved
    • None
    • API - REST
    • None
    • We collect Bitbucket feedback from various sources, and we evaluate what we've collected when planning our product roadmap. To understand how this piece of feedback will be reviewed, see our Implementation of New Features Policy.

      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 ~ % 
      

              Unassigned Unassigned
              8c8205d742ae Priyata Waje
              Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated: