fix: clarify bodyless Confluence content errors#206
Merged
Conversation
read/edit/update commands crashed with an opaque "TypeError: Cannot read properties of undefined (reading 'value')" when the target content has no body.storage, such as a Confluence folder. Guard the three storage-body accesses in readPage, updatePage (reuse-content path), and getPageForEdit via a shared requireStorageBody helper that surfaces an actionable message instead. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
🎉 This PR is included in version 2.14.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intent
Fix a reproduced crash where 'confluence read'/'edit'/'update' die with an opaque 'TypeError: Cannot read properties of undefined (reading value)' when the target content has no body (e.g. a Confluence folder, creatable via 'confluence create --type folder'). Root cause: three unguarded accesses to response.data.body.storage.value in lib/confluence-client.js — readPage, updatePage's reuse-existing-content path, and getPageForEdit. Folder content has no body.storage so .value throws; 'confluence info' already works on folders via the null-safe normalizePage, making this an internal inconsistency. Fix: added a shared helper requireStorageBody(data, pageId) that null-safely reads body.storage.value and throws a clear, consistent, actionable message ('Page has no readable body (it may be a folder or an unsupported content type).') instead of the cryptic TypeError, and routed all three sites through it. Deliberately kept one shared helper for message consistency; normal pages with a body are intentionally unchanged. Added focused regression tests in tests/confluence-client.test.js ('bodyless content (folder) handling') covering readPage, getPageForEdit, and the updatePage reuse-content path, asserting the clear message and that the TypeError no longer surfaces. Full suite (747 tests) green and eslint clean.
What Changed
TypeError.read,edit, and title-onlyupdateflows while preserving normal page storage-body behavior.Risk Assessment
✅ Low: The change is narrowly scoped to replacing three unsafe body lookups with a null-safe helper and focused regression coverage, and I found no material risks introduced by the branch.
Testing
After fixing the setup issue with
npm ci, the focused regression selector and fulltests/confluence-client.test.jspassed; the CLI transcript showsread,edit, and title-onlyupdatenow return the clear bodyless-content error with no TypeError, while normal page read/edit/update still succeed and title-only update reuses the existing storage body.node_moduleswas removed afterward and the worktree is clean.Evidence: Confluence CLI bodyless and normal transcript
Evidence: Bodyless folder CLI transcript
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
✅ **Review** - passed
✅ No issues found.
✅ **Test** - passed
✅ No issues found.
npm test -- --runTestsByPath tests/confluence-client.test.js -t "bodyless content \\(folder\\) handling|readPage should return storage content when format is storage|updatePage with format=\\\"auto\\\" converts plain text to storage"initially exposed missing local dependencies (jest: command not found).npm cito install project dependencies for testing.npm test -- --runTestsByPath tests/confluence-client.test.js -t "bodyless content \\(folder\\) handling|readPage should return storage content when format is storage|updatePage with format=\\\"auto\\\" converts plain text to storage"after dependency install.node <<'NODE' ...evidence generator running realnode bin/index.js read/edit/updatecommands against a local HTTP Confluence stub for bodyless folder content and normal page content; transcript saved under the requested evidence directory.npm test -- --runTestsByPath tests/confluence-client.test.js.rm -rf node_modulescleanup, followed bygit status --shortand evidence-directory checks.✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.