Creating a space via REST API returns HTTP 500 (instead of 4xx) for space key lengths in the 246–255 character range

XMLWordPrintable

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Low
    • Component/s: Space - Create
    • None
    • 1
    • Minor

      Issue Summary

      Creating a space via the Confluence Cloud REST API (both v1 `POST /wiki/rest/api/space` and v2 `POST /wiki/api/v2/spaces`) returns HTTP 500 with an internal stack trace whenever the space key is between {}246 and 255 characters{}, even though shorter keys succeed and keys longer than 255 are correctly rejected with a structured HTTP 400.

      For affected key lengths the request appears to pass initial validation but fails during downstream processing, producing an unhandled exception. The result is an inconsistent : clean success below 246, clean validation error above 255, but an unhandled 500 in between.

      Steps to Reproduce

      1. Set up an Atlassian API token for any Confluence Cloud site.
      2. Send a create-space request with a 250-character key:
      3. Repeat with a 246, 248, or 255-character key. Repeat against the v2 endpoint (`/wiki/api/v2/spaces`). Repeat with shorter and longer keys to observe the boundary.

      Expected Results

      For a 250-character key (under the 255-character limit shown in the validator's error message), one of:

      • HTTP 200 / 201 — space created successfully, OR
      • HTTP 400 with a structured validation message, identical in shape to the response returned for keys longer than 255.

      Actual Results

      For any key in the 246–255 character range, both v1 and v2 endpoints return HTTP 500 with an internal stack trace exposed in the response body:

      {
        "statusCode": 500,
        "message": "java.lang.RuntimeException: could not execute batch; SQL [...suppressed]; nested exception is org.hibernate.exception.DataException: could not execute batch."
      }
      

      Observed behaviour across the boundary (5 attempts per length, both endpoints):

      Key length HTTP status Response shape
      1 → 245 200 / 201 Successful create
      246 → 255 {}500{} {}Unhandled exception{}
      256+ 400 Structured `BAD_REQUEST` with a translated message

      The 246–255 range is the only zone where the API returns a 500. Keys longer than 255 receive a clean validation error stating that the maximum is 255, confirming that the server-side validator infrastructure works correctly outside of this range.

      Workaround

      Keep space keys at {}245 characters or fewer{}

              Assignee:
              Unassigned
              Reporter:
              Abhinay Nigam
              Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated: