jckleiner / notion-backup

Automatic Notion workspace backup to Google Drive, Dropbox, pCloud, Nextcloud or to your local machine.
86 stars 33 forks source link

Backup fails on different network / arm64 - Unexpected character '<' #10

Closed orellazri closed 1 year ago

orellazri commented 1 year ago

When trying to back up on an ARM (linux/arm64/v8) machine (using Docker, normal local backup), it fails with:

08:40:03.316 [main] INFO com.greydev.notionbackup.NotionBackup - ---------------- Starting Notion Backup ----------------
08:40:03.725 [main] INFO com.greydev.notionbackup.NotionClient - DOWNLOADS_DIRECTORY_PATH is not set. Downloads will be saved to: /downloads
08:40:03.726 [main] INFO com.greydev.notionbackup.NotionClient - Using export type: markdown
08:40:03.728 [main] INFO com.greydev.notionbackup.NotionClient - Flatten export file tree: false
08:40:04.272 [main] WARN com.greydev.notionbackup.NotionClient - Exception during export
com.fasterxml.jackson.core.JsonParseException: Unexpected character ('<' (code 60)): expected a valid value (JSON String, Number, Array, Object or token 'null', 'true' or 'false')
 at [Source: (String)"<!DOCTYPE html>
<html>
        <head>
                <meta charset="utf-8" />
                <title>Notion</title>
                <style type="text/css">*{box-sizing:border-box}html{margin:0;padding:0}body{-webkit-font-smoothing:auto;align-items:center;background:#fffefc;color:#37352f;display:flex;flex-direction:column;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Apple Color Emoji,Arial,sans-serif,Segoe UI Emoji,Segoe UI Symbol;height:100vh;justify-content:center;justify-content:space-between;line-height:1.5;margin:0;padd"[truncated 10945 chars]; line: 1, column: 2]
        at com.fasterxml.jackson.core.JsonParser._constructError(JsonParser.java:1922)
        at com.fasterxml.jackson.core.base.ParserMinimalBase._reportError(ParserMinimalBase.java:710)
        at com.fasterxml.jackson.core.base.ParserMinimalBase._reportUnexpectedChar(ParserMinimalBase.java:635)
        at com.fasterxml.jackson.core.json.ReaderBasedJsonParser._handleOddValue(ReaderBasedJsonParser.java:1952)
        at com.fasterxml.jackson.core.json.ReaderBasedJsonParser.nextToken(ReaderBasedJsonParser.java:781)
        at com.fasterxml.jackson.databind.ObjectMapper._readTreeAndClose(ObjectMapper.java:4620)
        at com.fasterxml.jackson.databind.ObjectMapper.readTree(ObjectMapper.java:3042)
        at com.greydev.notionbackup.NotionClient.triggerExportTask(NotionClient.java:167)
        at com.greydev.notionbackup.NotionClient.export(NotionClient.java:98)
        at com.greydev.notionbackup.NotionBackup.main(NotionBackup.java:56)
Exception in thread "main" java.lang.IllegalStateException: Could not export notion file
        at com.greydev.notionbackup.NotionBackup.lambda$main$0(NotionBackup.java:57)
        at java.base/java.util.Optional.orElseThrow(Optional.java:408)
        at com.greydev.notionbackup.NotionBackup.main(NotionBackup.java:57)

I can successfully back up on different machines with the default amd64 image. I'm not sure what is the root cause, but it can also be something else since this machine is in a different network. I can't seem to reproduce this issue on other machines, even when building and running the image in the arm64 arch.

It seems to fail around this part: https://github.com/jckleiner/notion-backup/blob/25265a34548d271d6d8c36259c54eebe3ed41083/src/main/java/com/greydev/notionbackup/NotionClient.java#L165-L167

orellazri commented 1 year ago

Update: I think it's not related to the image architecture, but it's something in the network. It seems like the response from the url is not the expected json when trying back up over a different network.

orellazri commented 1 year ago

As this issue seems to be related to me I will close it, but just in case someone stumbles here, I used a VPN container (gluetun) and ran this notion-backup container with the same network, and it appears to solve the issue.