Bitbucket REST API returns HTTP 500 instead of 413/400 when repository hook settings exceed 32KB LOB limit

XMLWordPrintable

    • Type: Suggestion
    • Resolution: Unresolved
    • None
    • Component/s: Database Support
    • None
    • 1
    • 1

      Problem Statement

      When updating repository hook settings via the REST API, if the serialized settings exceed the hardcoded 32,768-byte LOB limit, Bitbucket returns an HTTP 500 Internal Server Error. The server logs correctly identify the validation failure (java.lang.IllegalArgumentException: The provided LOB data is too long), but this is not surfaced to the REST client.

      This prevents automation and API consumers from distinguishing a "Payload Too Large" validation error from a transient server-side failure, leading to inappropriate retries.

      Environment

      • Product: Bitbucket Data Center
      • Version: 9.4.19 (and likely all versions using InternalSharedLob)
      • Database: Any (Limit is enforced at the application layer)

      Steps to Reproduce

      1. Install a repository hook that uses the standard settings persistence (e.g., a Java-based PreRepositoryHook).
      1. Generate a valid JSON payload where a setting value causes the total serialized size to exceed 32,768 bytes.
        • Example: {{ {"largeValue": "A" * 33000}

          }}

      1. Send a PUT request to the hook's configuration endpoint:
        PUT /rest/api/1.0/projects/{project}/repos/{repo}/settings/hooks/{hookKey}/enabled
      1. Observe the HTTP response code and the server logs.

      Expected Results

      The REST API should return a client-side error:

      • HTTP 413 Payload Too Large (Preferred, per RFC 9110) or HTTP 400 Bad Request.
      • The response body should contain a machine-readable error message indicating that the LOB size limit was exceeded.

      Actual Results

      • HTTP Status: 500 Internal Server Error
      • Response Body: Generic or empty.
      • Server Logs:

       
       {{ c.a.s.i.r.e.DefaultUnhandledExceptionMapperHelper Unhandled exception while processing REST request java.lang.IllegalArgumentException: The provided LOB data is too long at com.google.common.base.Preconditions.checkArgument(Preconditions.java:143) at com.atlassian.stash.internal.setting.InternalSharedLob$Builder.data(InternalSharedLob.java:88) at com.atlassian.stash.internal.repository.InternalRepositoryHook$Builder.settings(InternalRepositoryHook.java:224)}}

      Notes

      This is not a request to increase the 32KB limit. It is a request to improve error handling so that the IllegalArgumentException thrown by InternalSharedLob$Builder is caught and mapped to an appropriate HTTP status code rather than falling through to the DefaultUnhandledExceptionMapperHelper.

              Assignee:
              Unassigned
              Reporter:
              Marco Araujo
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated: