antora-confluence icon indicating copy to clipboard operation
antora-confluence copied to clipboard

Cannot read properties of undefined (reading 'pageTitle')

Open beyondlex opened this issue 1 year ago • 7 comments

When I execute the antora command, i get the following error:

info:     Publishing Dash to Confluence
info:     Initializing state
info:     Decoding Confluence state
info:     Removing untracked pages
info:     Publishing pages
info:     Processing worktree.html
[17:30:07.783] FATAL (antora): Cannot read properties of undefined (reading 'pageTitle')

Here is my configuration:

output:
  destinations:
    - provider: fs
    - provider: antora-confluence
      confluence-api: http://.../rest/api
      confluence-space: 'myspace'
      ancestor-id: 1016484
      filter:
        - path: tool/git

Is there something wrong with my configuration? Thank you for your help!

beyondlex avatar Jul 25 '24 09:07 beyondlex

I forked the code and debugged it. I found that the issue lies with the filter. The filter restricts the pages involved in the current generation, but the pages reference other pages that are not included in this generation, causing the error.

beyondlex avatar Jul 25 '24 09:07 beyondlex

Thanks for contributing! Until now, filtering pages means you need to take care of the "page dependencies" to avoid broken links. The PR now would introduce a behaviour that makes it legit to have broken links and i am not sure about that. Maybe we should cover this with an explicit knob to be configured to actively agree that this is intended, instead of implicitly forcing that. What do you think? I could think of a setting like ignore_broken_links?

PacoVK avatar Jul 25 '24 17:07 PacoVK

Yes, I completely agree with your point of view. Some people prefer to ignore non-existent references to prioritize passing the compilation, while others prefer the compilation to fail to highlight which reference files were missed. Providing an option is the right approach.

beyondlex avatar Jul 26 '24 03:07 beyondlex

just checking to avoid duplicate efforts, @beyondlex are you working on this and come up with a PR at some point? (no time pressure) :)

PacoVK avatar Aug 15 '24 12:08 PacoVK

I found out that exactly the same error (Cannot read properties of undefined (reading 'pageTitle')) happens if one page attempts to reference an element inside other page using xref:other-page.adoc#fragment-id[text] syntax even if the xref is absolutely correct:

[17:16:05.033] FATAL (antora): Cannot read properties of undefined (reading 'pageTitle')
    Cause: TypeError
        at C:\Users\marat\OneDrive\Documents\ssg1\docs\node_modules\antora-confluence\dist\lib\transformer\LinkTransformer.js:101:140
        at Array.forEach (<anonymous>)
        at rewriteInternalLinks (C:\Users\marat\OneDrive\Documents\ssg1\docs\node_modules\antora-confluence\dist\lib\transformer\LinkTransformer.js:80:41)
        at convertHtmlToConfluence (C:\Users\marat\OneDrive\Documents\ssg1\docs\node_modules\antora-confluence\dist\lib\service\HtmlToConfluenceConverter.js:22:69)
        at processPage (C:\Users\marat\OneDrive\Documents\ssg1\docs\node_modules\antora-confluence\dist\lib\service\PageService.js:288:94)
        at publish (C:\Users\marat\OneDrive\Documents\ssg1\docs\node_modules\antora-confluence\dist\lib\service\PageService.js:178:40)
        at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
        at async publishToConfluence (C:\Users\marat\OneDrive\Documents\ssg1\docs\node_modules\antora-confluence\dist\index.js:39:9)
        at async Promise.all (index 1)
        at async generateSite (C:\Users\marat\OneDrive\Documents\ssg1\docs\node_modules\@antora\site-generator\lib\generate-site.js:53:12)

UPD: Correction, this only happens if I have html_extension_style: indexify in my antora-playbook.yml.

slonopotamus avatar Sep 19 '24 14:09 slonopotamus

Hi @PacoVK , I got the same message when trying to include an image using image::example-form.png[link=self] (having read that it's not supported yet but on your roadmap). Just to let you know that there are other reasons for the same error message.

Kind regards Henning

lucom-hm avatar Oct 15 '24 16:10 lucom-hm

I'm in the same situation where broken links completely lock me out. I'm dealing with tens of repos, it's not possible for me to go and fix all the links. ignore-broken-links would be a savior. Untill then I'm locked out. :(

koriit-kontakt avatar Sep 02 '25 14:09 koriit-kontakt