{"record":{"id":"fa09717fcaa934df","repo":"jackwener/OpenCLI","slug":"confluence-update-could-not-determine-the-current","errorCode":null,"errorMessage":"confluence update could not determine the current page version.","messagePattern":"confluence update could not determine the current page version\\.","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/confluence/shared.js","lineNumber":104,"sourceCode":"        };\n    }\n    return {\n        type: 'page',\n        status: 'current',\n        title,\n        space: { key: space },\n        ...(args.parent ? { ancestors: [{ id: String(args.parent) }] } : {}),\n        body: { storage: { representation: 'storage', value: storage } },\n    };\n}\n\nexport function updatePagePayload(config, current, args, storage) {\n    const page = requirePayloadObject(current, 'confluence current page');\n    const id = requirePayloadString(page.id, 'page id', 'confluence current page');\n    const title = args.title ? requireString(args.title, 'Confluence page title') : requirePayloadString(page.title, 'title', 'confluence current page');\n    const currentVersion = Number(page.version?.number);\n    if (!Number.isSafeInteger(currentVersion) || currentVersion < 1) {\n        throw new CommandExecutionError('confluence update could not determine the current page version.');\n    }\n    const nextVersion = currentVersion + 1;\n    if (config.deployment === 'cloud') {\n        return {\n            id,\n            status: 'current',\n            title,\n            body: { representation: 'storage', value: storage },\n            version: {\n                number: nextVersion,\n                ...(args['version-message'] ? { message: String(args['version-message']) } : {}),\n            },\n        };\n    }\n    return {\n        id,\n        type: 'page',\n        status: 'current',","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/confluence/shared.js#L86-L122","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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"],"exampleFix":"// before\nconst page = await res.json(); // fetched without version expand\nawait confluenceUpdate({ id: page.id, title: page.title });\n// after\nconst page = await fetch(`${base}/rest/api/content/${id}?expand=version`).then(r => r.json());\nawait confluenceUpdate({ id: page.id, title: page.title, version: page.version });","handlingStrategy":"validation","validationCode":"function assertUpdatablePage(page) {\n  const v = Number(page?.version?.number);\n  if (!Number.isSafeInteger(v) || v < 1) {\n    throw new Error('page payload missing version.number — re-fetch with ?expand=version');\n  }\n}\nassertUpdatablePage(currentPage); // before calling the update command","typeGuard":"function hasConfluenceVersion(p) {\n  return typeof p === 'object' && p !== null &&\n    Number.isSafeInteger(Number(p.version?.number)) && Number(p.version?.number) >= 1;\n}","tryCatchPattern":"try {\n  await runCli('confluence update', ...);\n} catch (e) {\n  if (/could not determine the current page version/.test(e.message)) {\n    const fresh = await fetch(`${base}/rest/api/content/${id}?expand=version`).then(r => r.json());\n    return retryUpdateWithPage(fresh);\n  }\n  throw e;\n}","preventionTips":["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"],"tags":["confluence","version-conflict","missing-field","payload"],"backgroundTag":"missing-required-field","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}