jackwener/OpenCLI · error · CommandExecutionError
confluence update could not determine the current page versi
Error message
confluence update could not determine the current page version.
What it means
This CommandExecutionError is thrown by updatePagePayload (shared between Confluence update commands) when the fetched 'current page' payload lacks a usable version.number. Confluence's REST update API requires optimistic-locking with version.number = existing + 1, so without a valid current version the library refuses to build the update payload rather than send a corrupt request. Number(page.version?.number) must be a safe integer >= 1.
Source
Thrown at clis/confluence/shared.js:104
};
}
return {
type: 'page',
status: 'current',
title,
space: { key: space },
...(args.parent ? { ancestors: [{ id: String(args.parent) }] } : {}),
body: { storage: { representation: 'storage', value: storage } },
};
}
export function updatePagePayload(config, current, args, storage) {
const page = requirePayloadObject(current, 'confluence current page');
const id = requirePayloadString(page.id, 'page id', 'confluence current page');
const title = args.title ? requireString(args.title, 'Confluence page title') : requirePayloadString(page.title, 'title', 'confluence current page');
const currentVersion = Number(page.version?.number);
if (!Number.isSafeInteger(currentVersion) || currentVersion < 1) {
throw new CommandExecutionError('confluence update could not determine the current page version.');
}
const nextVersion = currentVersion + 1;
if (config.deployment === 'cloud') {
return {
id,
status: 'current',
title,
body: { representation: 'storage', value: storage },
version: {
number: nextVersion,
...(args['version-message'] ? { message: String(args['version-message']) } : {}),
},
};
}
return {
id,
type: 'page',
status: 'current',View on GitHub (pinned to 49907e53dc)
Solutions
- Re-fetch the page via the single-page GET endpoint (e.g. GET /rest/api/content/{id}?expand=version) so version.number is present
- If constructing the object manually, include version.number matching the page's current version (visible in page history)
- Verify you're using the same Confluence deployment type (cloud vs server) the library expects; shapes differ
- Check the page payload actually resolved (requirePayloadObject passed) and that version wasn't stripped by your own mapping code
Example fix
// before
const page = await res.json(); // fetched without version expand
await confluenceUpdate({ id: page.id, title: page.title });
// after
const page = await fetch(`${base}/rest/api/content/${id}?expand=version`).then(r => r.json());
await confluenceUpdate({ id: page.id, title: page.title, version: page.version }); Defensive patterns
Strategy: validation
Validate before calling
function assertUpdatablePage(page) {
const v = Number(page?.version?.number);
if (!Number.isSafeInteger(v) || v < 1) {
throw new Error('page payload missing version.number — re-fetch with ?expand=version');
}
}
assertUpdatablePage(currentPage); // before calling the update command Type guard
function hasConfluenceVersion(p) {
return typeof p === 'object' && p !== null &&
Number.isSafeInteger(Number(p.version?.number)) && Number(p.version?.number) >= 1;
} Try / catch
try {
await runCli('confluence update', ...);
} catch (e) {
if (/could not determine the current page version/.test(e.message)) {
const fresh = await fetch(`${base}/rest/api/content/${id}?expand=version`).then(r => r.json());
return retryUpdateWithPage(fresh);
}
throw e;
} Prevention
- Always fetch pages with ?expand=version before updating
- Never hand-construct page payloads without version.number
- Re-fetch fresh page state instead of reusing stale/cached JSON
- Confirm cloud vs server API matches your Confluence deployment
When it happens
Trigger: Calling a `confluence update`-family command where the current page object passed to payload()/updatePagePayload came from a response without version info — e.g. a page fetched via a search endpoint that omits version, a manually constructed object missing version.number, or an ATLAS/cloud vs server response-shape mismatch (version under a different key).
Common situations: Caching page JSON from an endpoint that doesn't include version (like some search results), copying example payloads that omit version, Confluence Server vs Cloud API differences, or a previous update corrupting the stored page object.
Understand the failure class
Background: "Missing required field" and "field is required" errors: why libraries reject payloads that omit mandatory fields — this error's family across 20 libraries.
Related errors
- ${label} did not include a stable ${field}.
- ${label} returned an unexpected payload shape; expected an o
- ${label} returned an unexpected payload shape; expected an a
- Bilibili comments reply ${index + 1} was missing rpid
- Bilibili comments reply ${index + 1} was missing ctime
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/fa09717fcaa934df.
Report an issue: GitHub.