Confluence page position - why is it sometimes missing? How to sort in this case?

I need to get the page order (that is: sort order of a page’s children in the page tree) from Confluence. In the Confluence Cloud there is thankfully the position attribute that is set for returned content objects.

For example the rest/api/content/CONTENTID endpoint result includes:

"extensions": {
  "position": 175485145
}

The position seems to be included in most endpoint’s results, which is nice. Simply sorting children of a parent page by position gives the order as displayed in the page tree.

Now, I also got lots of pages where the following is returned instead (via any v1 endpoint):

"extensions": {
  "position": "none"
}

Or when getting via v2 endpoint:

"position": null

What does that mean?

I cannot reproduce this in any way with new, manually created content. The position will always be set in those cases, even when sorting all children of a page alphabetically (via Space Settings → Manage Content → Reorder).

Now, the content where position is none has been migrated from Confluence on-prem to the cloud and I suspect this might play a role. But this is only a theory.

With regard to determining the page order - should I assume alphabetic order when the position is none/null? Or how to interpret and handle this?

Any explanation is appreciated.

Regarding the order of child pages, I recently discovered a case where only ONE child has the position set (like 756151671), all other sibling pages have no position set.

This ONE page has been created in the cloud, the other pages are older and have been migrated from on-prem.

Looking at the page trees I see two different sorting behaviors:

The new, modern page tree on the left side sorts all alphabetically and apparently ignores the position of the ONE page.

The old page tree that you access via the space settings to reorder the pages shows the ONE page on top of all pages. So it’s page ONE, then all other pages sorted alphabetically.

Sigh.

More insights: adding a new sibling page initialized the position of all sibling pages.

Strangely enough, when doing so, page ONE (the one with the existing position value in my test case) changed its position and moved to the top when doing this.

My takeway of how things work is:

  1. pages that have been migrated from Confluence on-prem to Confluence Cloud have no position value set (maybe only for alphabetically sorted pages…?)
  2. somehow it is/was possible to add sibling pages that have a position set, while still leaving its siblings without a position value; such a mix of pages is sorted alphabetically, at least in the left tree
  3. when adding a page the (so far missing) position value of all sibling pages is set; the position now determines the sort order

Points 2 and 3 are at odds. Nevertheless, this is what I experienced.