Page numbering bug: both while referencing by script and in UI
InDesign CC version 16.2.1 x 64 on Windows 10
Let’s make a test:
Create a new document using the default settings: the single page only, page numbering starts at 1, and run this one-liner:
alert(app.activeDocument.pages.itemByName(app.activeDocument.pages[0].name).name);So far so good:

Now change 'start page number at' from the default ‘1’ in the numbering & section options to, say, ‘2’.
Note: the page moves to the left, but the pages panel shows 1 instead of 2 which is wrong!

Running the script now results in the ‘object is invalid’ error.
Then I got out of the pantry my old, covered with dust, notebook with InDesign CS3 and found out that the bug wasn’t present in that version: everything works as expected.

I noticed a post in the InDesign Scripting Forum group on Facebook: a guy reported that the pre-installed AdjustPageItems.jsx script didn't work for him throwing the error. When I looked into the problem, I discovered the bug.
I wonder when it was introduced? Is it present in the latest version 16.3? (We still don't have this update available here in Ukraine for some reason).
— Kas
