cosmere icon indicating copy to clipboard operation
cosmere copied to clipboard

Cosmere crashes with `TypeError: Cannot read property 'filter' of undefined`

Open codethief opened this issue 1 year ago • 6 comments

It's been a while since I've used Cosmere, so I just upgraded to v0.16.0 of Cosmere and it now crashes when running npx cosmere:

$ npx cosmere
▶  start     Starting to render "posts/test.md"
✖  fatal     TypeError: Cannot read property 'filter' of undefined

My cosmere.json:

{
  "baseUrl": "<BASE_URL>",
  "personalAccessToken": "<TOKEN>",
  "cachePath": "build",
  "prefix": "This blog post was automatically converted from Markdown. For comments please use the comment section below as inline comments will get lost when re-uploading",
  "pages": [
    {
      "pageId": "<POST_ID>",
      "file": "posts/test.md",
      "title": "Test"
    }
  ]
}

The file posts/test.md is empty but the same error occurs with any other file I've tried.

codethief avatar May 08 '23 16:05 codethief

The issue seems to be this line. Replacing remoteAttachments with (remoteAttachments || []) seems to fix the issue. However, in this case another exception is thrown on line https://github.com/mihaeu/cosmere/blob/main/src/UpdatePage.ts#L50:

TypeError: Cannot read property 'storage' of undefined
    at isRemoteUpdateRequired

This is starting to look like an API mismatch?

codethief avatar May 09 '23 17:05 codethief

Hey 👋 welcome back and thanks for the report. This week is a bit tricky, but I'll try to check it out asap.

Are you using this on a hosted or cloud Confluence?

mihaeu avatar May 10 '23 08:05 mihaeu

Thanks for the quick response and the warm welcome. :)

It's a hosted instance. According to the team responsible for it, last time I ran cosmere successfully they were running Confluence v7.13.0. Currently it's 7.13.7. So an API change is starting to look unlikely. Looks like I'll to have to debug the network requests… sigh. :)

codethief avatar May 10 '23 17:05 codethief

I also checked and newest versions, even Confluence Cloud works just fine. I've been facing a couple of those in the last few patches. The markdown converter I'm using as a base made a lot of incompatible changes, but the old version has major security issues :( this doesn't seem to be the case for your example however :thinking:

Is the old version of cosmere still working for you? Are there maybe some attachments uploaded to which the API user has no access to? Trying to figure out how to reproduce this.

mihaeu avatar May 19 '23 08:05 mihaeu

Good news is that I figured out that Atlassian hands out free developer accounts and I got my hands on one. So now I can add integration tests against an actual instance to the GitHub actions which should make future updates a lot safer :crossed_fingers:

mihaeu avatar May 19 '23 08:05 mihaeu

Is the old version of cosmere still working for you?

No, unfortunately it doesn't. :\

Are there maybe some attachments uploaded to which the API user has no access to?

I created a new page from scratch, so there shouldn't be any attachments.

As for integration tests: That's great news! Once those integration tests are in place, maybe I could run them against our instance to see what's up.

codethief avatar May 19 '23 19:05 codethief