Confluence REST API error 500 when searching for space with NULL description

XMLWordPrintable

    • 1
    • Severity 3 - Minor

      Problem

      When using the Confluence DC REST API to search for spaces and request to expand the description, an error 500 occurs when the value of spacedescid is set as NULL in the spaces table.

      /rest/api/space?expand=description

      Environment

      Confluence DC

      Steps to Reproduce

      1. Create a space in Confluence
      2. Set a space description
      3. Set the value for spacedescid as NULL in the database using the space key
        UPDATE spaces
        SET spacedescid = NULL
        WHERE spacekey = <Space Key>;
        
      4. Clear Confluence DC cache
      5. Send a request to Confluence REST API for the space with an expand=description
        <Base URL>/rest/api/space/<Space Key?expand=description

      Expected Results

      Actual Results

      An error 500 will be returned to the request, and you can find the following entries in the logs.

      2024-11-21 11:36:36,849 ERROR [http-nio-8090-exec-11 url: /confluence/rest/api/latest/space; user:-] [rest.api.model.ExceptionConverter] convertServiceException No status code found for exception, converting to internal server error : 
       -- url: /confluence/rest/api/latest/space | userName: - | traceId: -
      com.atlassian.confluence.api.impl.pagination.BatchExecutionException: Error during batch execution with session management
      ...
      Caused by: java.lang.NullPointerException: Cannot invoke "com.atlassian.confluence.spaces.SpaceDescription.getBodyAsString()" because the return value of "com.atlassian.confluence.spaces.Space.getDescription()" is null
      

      Workaround

      1. Find the affected space with the following query
        SELECT * FROM spaces s
        WHERE s.spacedescid IS NULL
        
      2. Get the Space Key and navigate to edit its description
        <Base URL>/spaces/editspace.action?key=<Space Key>
      3. Update the space description and save

            Assignee:
            Christopher Jones (Inactive)
            Reporter:
            Leonardo Clausen (Inactive)
            Votes:
            13 Vote for this issue
            Watchers:
            12 Start watching this issue

              Created:
              Updated:
              Resolved: