Skip to content

fix(confluence): handle undefined page title crash in slugifyTitle#9

Merged
BjoernSchotte merged 2 commits into
BjoernSchotte:mainfrom
twogood:copilot/add-unit-test-for-confluence-error
May 15, 2026
Merged

fix(confluence): handle undefined page title crash in slugifyTitle#9
BjoernSchotte merged 2 commits into
BjoernSchotte:mainfrom
twogood:copilot/add-unit-test-for-confluence-error

Conversation

@twogood

@twogood twogood commented Apr 28, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes a crash when pulling Confluence pages where the API returns a page with a missing (undefined) title:

undefined is not an object (evaluating 'title.toLowerCase')

This happened because slugifyTitle unconditionally called .toLowerCase() on its argument, but the Confluence API can return pages without a title field at runtime despite the TypeScript typing.

Changes

Commit 1 — failing test (packages/confluence/src/hierarchy.test.ts):

  • Adds a test that passes undefined as the page title to computeFilePath, reproducing the crash

Commit 2 — fix (packages/confluence/src/atlcli-dir.ts):

  • Changes slugifyTitle signature from title: string to title: string | undefined | null
  • Returns "" early for falsy input so the existing || "page" fallback in computeFilePath handles it gracefully

@BjoernSchotte BjoernSchotte merged commit 46d0c81 into BjoernSchotte:main May 15, 2026
2 checks passed
@BjoernSchotte

Copy link
Copy Markdown
Owner

Thanks again, David! Clean fix — the widened type signature + early return is exactly the right approach for an API-boundary type mismatch like this. Squash-merged into main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants