BUG: using cql to retrieve page data truncates page title

Currently I have pages titled in the format
<company_page_id> - <.page description>

As time goes by the <.page description> may be changed based on a central database but the <company_page_id> is constant.

As such I needed to use the API search for pages that start with <company_page_id>. The only way I could make this work was using cql but when the title is returned it is truncated. See below

def get_page_using_id_cql(title_filter: str) -> dict:
    cql = f"type = page and {title_filter} order by title"

    res = confluence.cql(
        cql,
        start=0,
        limit=100,
        expand=True,
        include_archived_spaces=None,
        excerpt=None,
    )["results"][0]

    return res['content']['title']


def get_pages_by_title_wildcard_cql(title_filter: str) -> dict:
    cql = f'type = page and title ~ "{title_filter}" order by title'

    res = confluence.cql(
        cql,
        start=0,
        limit=100,
        expand=True,
        include_archived_spaces=None,
        excerpt=None,
    )["results"]

    # Filter results that start with wildcard query
    res = [
        x['content']['title'] for x in res
        if x['content']['title'].startswith(title_filter)
    ]

    if res:
        return res[0]

    return ""


def get_page_by_id(pageid):
    res = confluence.get_page_by_id(pageid)

    return res['title']


page_id = <confluence_id>
company_page_id = "The quick"
print(get_page_using_id_cql(f'id = "{page_id}"'))
print(get_page_by_id(page_id))
print(get_pages_by_title_wildcard_cql(company_page_id))

for the page shown in image below

this results in

The quick brown fox jumps over the lazy dog abcdefghijklmnopqrstuvwxyz lorem ipsum dolor sit amet, consecteturadipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
The quick brown fox jumps over the lazy dog abcdefghijklmnopqrstuvwxyz lorem ipsum dolor sit amet, consecteturadipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
The quick brown fox jumps over the lazy dog abcdefghijklmnopqrstuvwxyz lorem ipsum dolor sit amet, consecteturadipiscing

The first two functions search using Confluence page id and the titles are complete
The third function searched by title using a substring and the returned title is truncated

Am I missing something?
Cheers for any input

Hello @DaraOhEidhin

I’ve replicated what you’ve described. The title object returned in the JSON response of a CQL content search using title ~ seems limited to 120 characters. Other methods of CQL searches for the same page return a title object in the JSON with the full title, up to the 255 character limit.

Very weird!

I’d suggest you first search the Confluence Cloud bugs to see if it has been previously logged by someone else. If not, log it as a new bug.

1 Like

After further investigation it seems to truncate the title by removing trailing words until the returned title id < 127 characters.

title -> "Thequickbrownfoxjumpsoverthelazydog Thequickbrownfoxjumpsoverthelazydog Thequickbrownfoxjumpsoverthelazydog Thequickbrownfoxjumpsoverthelazydog"""

returns "Thequickbrownfoxjumpsoverthelazydog Thequickbrownfoxjumpsoverthelazydog Thequickbrownfoxjumpsoverthelazydog"

BUG reported Using cql title search returns a truncated title <127 characters (atlassian.com)