Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read properties of undefined (reading 'pageTitle') #19

Closed
andreas-hempel opened this issue Mar 22, 2024 · 19 comments · Fixed by #21
Closed

Cannot read properties of undefined (reading 'pageTitle') #19

andreas-hempel opened this issue Mar 22, 2024 · 19 comments · Fixed by #21

Comments

@andreas-hempel
Copy link

Hello,

when running npx antora .\antora-playbook-confluence-local.yml --stacktrace I get the following error:

FATAL (antora): Cannot read properties of undefined (reading 'pageTitle')

Attached you will find a log file and the playbook.

Do you have any tips on how I can avoid this problem?

Many thanks and best regards,
Andreas Hempel

output.log
antora-playbook-confluence-local.txt

@PacoVK
Copy link
Owner

PacoVK commented Mar 22, 2024

@andreas-hempel thanks for raising this issue.
I will take a closer look, but probably not this week.
Another thing I will need to fix according the logs you provided is the encoding.
I'll keep you posted

@PacoVK
Copy link
Owner

PacoVK commented Apr 2, 2024

Hey @andreas-hempel thanks for your patience. I have a hard time to reproduce this. Would it be possible to send me a small reproducer? You can also contact me via LinkedIn for that :)

@andreas-hempel
Copy link
Author

Hello @PacoVK

Thank you for your feedback. I will try to reproduce the error in a new project this week. The current project where the error occurs is slightly larger. As soon as I can reproduce the error, I will make the project available to you.

Kind Regards,
Andreas

@PacoVK
Copy link
Owner

PacoVK commented Apr 8, 2024

Sounds good thanks for your help!

@andreas-hempel
Copy link
Author

Hello @PacoVK,

I was able to reproduce the problem in a new project. You can find the project attached.

confluence-issue.zip

The error occurs when I insert an xref in the tables.adoc file to an anchor that is defined in the message-header.csv file. The message-header.csv file is used as include in the message-header.adoc file.

Kind Regards,
Andreas

@andreas-hempel
Copy link
Author

Here is my console output

PS C:\dev\antora\confluence-issue> npm run build-confluence

> [email protected] build-confluence
> npx antora antora-playbook-confluence-local.yml --stacktrace

[17:56:44.120] INFO (@antora/lunr-extension): Building search index with the language(s): de
info:     Publishing Confluence Issue Demo to Confluence
info:     Initializing state
info:     Publishing pages
info:     Processing confluence-issue\main\index.html
info:     Creating page Einleitung
info:     Processing confluence-issue\main\segments.html
info:     Creating page HL7-Segmente
info:     Processing confluence-issue\main\tables.html
    Cause: TypeError
        at C:\dev\antora\confluence-issue\node_modules\antora-confluence\dist\lib\transformer\LinkTransformer.js:92:129
        at Array.forEach (<anonymous>)
        at rewriteInternalLinks (C:\dev\antora\confluence-issue\node_modules\antora-confluence\dist\lib\transformer\LinkTransformer.js:79:41)
        at processPage (C:\dev\antora\confluence-issue\node_modules\antora-confluence\dist\lib\service\PageService.js:299:52)
        at publish (C:\dev\antora\confluence-issue\node_modules\antora-confluence\dist\lib\service\PageService.js:184:40)
        at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
        at async publishToConfluence (C:\dev\antora\confluence-issue\node_modules\antora-confluence\dist\index.js:49:9)
        at async Promise.all (index 1)
        at async generateSite (C:\dev\antora\confluence-issue\node_modules\@antora\site-generator\lib\generate-site.js:53:12)
        at async Command.parseAsync (C:\dev\antora\confluence-issue\node_modules\commander\lib\command.js:935:5)

@PacoVK
Copy link
Owner

PacoVK commented Apr 11, 2024

Thanks for the reproducer, now i found the bug and already have most of the fix. I'll try to merge and release soon :)

@PacoVK
Copy link
Owner

PacoVK commented Apr 17, 2024

@andreas-hempel could you please also confirm whether 0.2.4 now fixes your issue?

@PacoVK PacoVK reopened this Apr 17, 2024
@andreas-hempel
Copy link
Author

andreas-hempel commented Apr 18, 2024

Hello @PacoVK,

I have tested version 0.2.4. and the error "Cannot read properties of undefined (reading 'pageTitle')" no longer occurs. However, I now get the error "Cannot read properties of undefined (reading 'number')". Here is the output on the console.

info:     Creating page Management Summary
info:     Processing oid\main\introduction.html
info:     Creating page undefined-Einleitung
info:     Processing oid\main\organizational.html
info:     Creating page Organisatorisches Konzept
info:     Processing index.html
info:     Creating Confluence state
info:     Creating page Captain State Page
[06:42:36.423] FATAL (antora): Cannot read properties of undefined (reading 'number')
    Cause: TypeError
        at createState (C:\dev\interoperability-platform\hl7-profile\node_modules\antora-confluence\dist\lib\service\StateService.js:52:41)
        at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
        at async publishToConfluence (C:\dev\interoperability-platform\hl7-profile\node_modules\antora-confluence\dist\index.js:50:9)
        at async Promise.all (index 1)
        at async generateSite (C:\dev\interoperability-platform\hl7-profile\node_modules\@antora\site-generator\lib\generate-site.js:53:12)
        at async Command.parseAsync (C:\dev\interoperability-platform\hl7-profile\node_modules\commander\lib\command.js:935:5)

I have also tested the project I have provided so that you can reproduce the error and I get the same error there.

I believe the same error is described in issue #11

Kind Regards,
Andreas

@PacoVK
Copy link
Owner

PacoVK commented Apr 18, 2024

Hey @andreas-hempel unfortunately it is not reproducable on my end, but i recognized Confluence seems to handle DRAFTs differently on some versions. I assume you are using Confluence on-prem? I am using Confluence Cloud. Will provide a new fix that should catch that error properly. Thanks for your support! Really appreciate it

@PacoVK
Copy link
Owner

PacoVK commented Apr 18, 2024

0.2.5 has the latest improvement, let's see if that fixes the issue on your end. BTW since 0.2.4 seems to fail on state creation, all resources on Confluence probably exist already. Captain failed after state creation, right?

@andreas-hempel
Copy link
Author

Hello @PacoVK,

we use confluence in the on-prem version. The error no longer occurs in version 0.2.5. Unfortunately, the corresponding pages are not created in confluence. There are also no pages to be found in the drafts. For testing purposes, I have simply used an incorrect password and then get a 401. Apparently the connection to confluence is successful, but the following API calls do not seem to work. Is there a way to increase the logging to get the API call displayed? I could then use Postman to check which error comes back from confluence and whether I can adjust the request accordingly to submit it successfully. Alternatively, we can also have a debugging session and we can reproduce this in my environment.

Best regards,
Andreas

@andreas-hempel
Copy link
Author

log output:

PS C:\dev\antora\confluence-issue> npm run build-confluence

> [email protected] build-confluence
> npx antora antora-playbook-confluence-local.yml --stacktrace

info:     Publishing Confluence Issue Demo to Confluence
info:     Initializing state
debug:    Could not extract a title, looking for any <h1> - undefined
debug:    Could not extract a title, looking for any <h2> MSH – Nachrichtenkopfinformationen
debug:    Could not extract a title, looking for any <h1> - Redirect Notice
debug:    Skipping _\css\site.css
debug:    Skipping _\font\roboto-cyrillic-400-italic.woff2
debug:    Skipping _\font\roboto-cyrillic-400-normal.woff2
debug:    Skipping _\font\roboto-cyrillic-500-italic.woff2
debug:    Skipping _\font\roboto-cyrillic-500-normal.woff2
debug:    Skipping _\font\roboto-latin-400-italic.woff
debug:    Skipping _\font\roboto-latin-400-italic.woff2
debug:    Skipping _\font\roboto-latin-400-normal.woff
debug:    Skipping _\font\roboto-latin-400-normal.woff2
debug:    Skipping _\font\roboto-latin-500-italic.woff
debug:    Skipping _\font\roboto-latin-500-italic.woff2
debug:    Skipping _\font\roboto-latin-500-normal.woff
debug:    Skipping _\font\roboto-latin-500-normal.woff2
debug:    Skipping _\font\roboto-mono-latin-400-normal.woff
debug:    Skipping _\font\roboto-mono-latin-400-normal.woff2
debug:    Skipping _\font\roboto-mono-latin-500-normal.woff
debug:    Skipping _\font\roboto-mono-latin-500-normal.woff2
debug:    Skipping _\img\back.svg
debug:    Skipping _\img\caret.svg
debug:    Skipping _\img\chevron.svg
debug:    Skipping _\img\home-o.svg
debug:    Skipping _\img\home.svg
debug:    Skipping _\img\menu.svg
debug:    Skipping _\img\octicons-16.svg
debug:    Skipping _\js\site.js
debug:    Skipping _\js\vendor\highlight.js
debug:    Skipping 404.html
debug:    Skipping sitemap.xml
info:     Publishing pages
info:     Processing confluence-issue\main\index.html
info:     Creating page Einleitung
info:     Processing confluence-issue\main\segments.html
debug:    Rewrite link to local anchor _msh_nachrichtenkopfinformationen
info:     Creating page HL7-Segmente
info:     Processing confluence-issue\main\tables.html
debug:    Rewrite link to other page with title HL7-Segmente original link was segments.html#MSH-8
info:     Creating page HL7-Tabellen
info:     Processing confluence-issue\main\segments\message-header.html
debug:    Rewrite link to local anchor _msh_nachrichtenkopfinformationen
info:     Creating page MSH – Nachrichtenkopfinformationen
info:     Processing index.html
info:     Creating Confluence state
debug:    Encoding {"Einleitung":{"fileName":"confluence-issue\\main\\index.html","pageTitle":"Einleitung","fqfn":"confluence-issue\\main\\index.html","id":"0aa020a0cca9e5f0cad3ae52d1046c1f"},"HL7-Segmente":{"fileName":"confluence-issue\\main\\segments.html","pageTitle":"HL7-Segmente","fqfn":"confluence-issue\\main\\segments.html","id":"66bd2b88d87f5ca6d8a8c65751fd75b9"},"HL7-Tabellen":{"fileName":"confluence-issue\\main\\tables.html","pageTitle":"HL7-Tabellen","fqfn":"confluence-issue\\main\\tables.html","id":"6eb885ed2b93673955eb633cb91a6266"},"MSH – Nachrichtenkopfinformationen":{"fileName":"confluence-issue\\main\\segments\\message-header.html","pageTitle":"MSH – Nachrichtenkopfinformationen","fqfn":"confluence-issue\\main\\segments\\message-header.html","id":"a28da6e9f8131e0f9999c8ea9b7d81f7"},"Redirect Notice":{"fileName":"index.html","pageTitle":"Redirect Notice","fqfn":"index.html","id":"eacf331f0ffc35d4b482f1d15a887d3b"}}
info:     Creating page Captain State Page
debug:    Decoding eJyNk0FuwjAQRa+CvIYqjrHjsK/EomVRWLIZ2zPEauLQxEiVEFLv0Bv2JA0gUKEg4p2lmT/vf4+37NmHEn3chBWbbBn5EmdQIZswWwcqNxgsjnzbbnC5rMCH5dIHh59PRaxKNmRrWOHCx3Lf8EdpyOiDQl8R77rKBCBJE0ishRwlJRacAJSp48lYWU5sN2TTl2w0x1WFIWJP2vZY3t4CvpB7iHytdKBWyrjUaO10RtKCchq0VTKTnFwmTX6iXoDBssTQkzqCKfEu81nsIfOlzpEYO1yJHXUuVCZyKdEoIazJOahUqT3x63w6+Pn6HszAFo23RcTwXq/JB6qbCqKvQ28np9S6O7ZtZ2RUIDhsbnnrNbb3O92beEgBUu1AYU6aC44J5d2xGiE3mdOcsn0Kb+h8gzYOZnX09nrh7n6D67Yz8P+dR7AkBKeEyArpxmasU+KOS9A6c8Kw3e4XHnQ+Ng==
Site generation complete!
Open file:///C:/dev/antora/confluence-issue/build/site/index.html in a browser to view your site.

@andreas-hempel
Copy link
Author

Hello @PacoVK,

I have created a collection in Postman to test the creation of a new page. The following call has successfully created the page on our Confluence server:

curl --location 'https://{{server}}:{{port}}/rest/api/content' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic {{secret}}' \
--header 'Cookie: JSESSIONID=80F70530944AF339682BE8DAC423C2D4' \
--data '{
    "type": "page",
    "title": "new page",
    "ancestors": [
        {
            "id": {{ancestorId}}
        }
    ],
    "space": {
        "key": "{{spaceKey}}"
    },
    "body": {
        "storage": {
            "value": "<h1>This is a new page</h1>",
            "representation": "storage"
        }
    }
}'

@andreas-hempel
Copy link
Author

I have looked at the implementation of your Confluence client and in line 30

the SpaceKey is set without inverted commas. If I remove the inverted commas in my example request in Postman, I get a 200 as a response, but nothing is created. If I make the call with inverted commas, the page is created successfully. #

@andreas-hempel
Copy link
Author

I tried something else to add some logging locally in the dist folder of the plugin. The url that is used looks like this https://{{server}}//rest/api/content. There are two slashes before the path. I simply adapted this locally to https://{{server}}/rest/api/content and was thus able to successfully create the pages in confluence.

@PacoVK
Copy link
Owner

PacoVK commented Apr 18, 2024

@andreas-hempel wow, thank you that is an important finding! Thanks again for investing your time into this issue.
Fix has been included into 0.3.0

@andreas-hempel
Copy link
Author

Hello @PacoVK,

I have installed and tested version 0.3.0. This has fixed the error.

Thank you very much for your support,
Andreas

@PacoVK
Copy link
Owner

PacoVK commented Apr 19, 2024

Great to hear it's finally working. Thanks again, your investigations made it quite a lot easier to fix 🚀

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 a pull request may close this issue.

2 participants