darobin / notion-backup

Simple command to backup a Notion workspace
MIT License
425 stars 63 forks source link

DecryptionError - Could not decrypt due to missing decryption metadata! #43

Open TomTruyen opened 1 month ago

TomTruyen commented 1 month ago

Not sure what is causing this. I have checked all my Secrets. I also tried to use both URL-decoded and encoded values for the tokenv2 and the file token.

The Notion App on my phone does still send me a push notification saying that my export is ready for some reason, though I am not sure if it is related to anything

Error: Request failed with status code 400
    at createError (/opt/hostedtoolcache/node/18.20.4/x64/lib/node_modules/notion-backup/node_modules/axios/lib/core/createError.js:16:15)
    at settle (/opt/hostedtoolcache/node/18.20.4/x64/lib/node_modules/notion-backup/node_modules/axios/lib/core/settle.js:17:12)
    at IncomingMessage.handleStreamEnd (/opt/hostedtoolcache/node/18.20.4/x64/lib/node_modules/notion-backup/node_modules/axios/lib/adapters/http.js:269:11)
    at IncomingMessage.emit (node:events:529:35)
    at endReadableNT (node:internal/streams/readable:1400:12)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  config: {
    url: 'enqueueTask',
    method: 'post',
    data: '{"task":{"eventName":"exportSpace","request":{"spaceId":"***","exportOptions":{"exportType":"markdown","timeZone":"America/New_York","locale":"en"},"shouldExportComments":false}}}',
    headers: {
      Accept: 'application/json, text/plain, */*',
      'Content-Type': 'application/json',
      Cookie: 'token_v2=***; file_token=***',
      'User-Agent': 'axios/0.21.4',
      'Content-Length': 212
    },
    baseURL: 'https://www.notion.so/api/v3',
    transformRequest: [ [Function: transformRequest] ],
    transformResponse: [ [Function: transformResponse] ],
    timeout: 0,
    adapter: [Function: httpAdapter],
    xsrfCookieName: 'XSRF-TOKEN',
    xsrfHeaderName: 'X-XSRF-TOKEN',
    maxContentLength: -1,
    maxBodyLength: -1,
    validateStatus: [Function: validateStatus],
    transitional: {
      silentJSONParsing: true,
      forcedJSONParsing: true,
      clarifyTimeoutError: false
    }
  },
  request: <ref *1> ClientRequest {
    _events: [Object: null prototype] {
      abort: [Function (anonymous)],
      aborted: [Function (anonymous)],
      connect: [Function (anonymous)],
      error: [Function (anonymous)],
      socket: [Function (anonymous)],
      timeout: [Function (anonymous)],
      finish: [Function: requestOnFinish]
    },
    _eventsCount: 7,
    _maxListeners: undefined,
    outputData: [],
    outputSize: 0,
    writable: true,
    destroyed: false,
    _last: true,
    chunkedEncoding: false,
    shouldKeepAlive: false,
    maxRequestsOnConnectionReached: false,
    _defaultKeepAlive: true,
    useChunkedEncodingByDefault: true,
    sendDate: false,
    _removedConnection: false,
    _removedContLen: false,
    _removedTE: false,
    strictContentLength: false,
    _contentLength: 212,
    _hasBody: true,
    _trailer: '',
    finished: true,
    _headerSent: true,
    _closed: false,
    socket: TLSSocket {
      _tlsOptions: [Object],
      _secureEstablished: true,
      _securePending: false,
      _newSessionPending: false,
      _controlReleased: true,
      secureConnecting: false,
      _SNICallback: null,
      servername: 'www.notion.so',
      alpnProtocol: false,
      authorized: true,
      authorizationError: null,
      encrypted: true,
      _events: [Object: null prototype],
      _eventsCount: [10](https://github.com/TomTruyen/notion-backups/actions/runs/11086489252/job/30804081343#step:6:11),
      connecting: false,
      _hadError: false,
      _parent: null,
      _host: 'www.notion.so',
      _closeAfterHandlingError: false,
      _readableState: [ReadableState],
      _maxListeners: undefined,
      _writableState: [WritableState],
      allowHalfOpen: false,
      _sockname: null,
      _pendingData: null,
      _pendingEncoding: '',
      server: undefined,
      _server: null,
      ssl: [TLSWrap],
      _requestCert: true,
      _rejectUnauthorized: true,
      parser: null,
      _httpMessage: [Circular *1],
      [Symbol(alpncallback)]: null,
      [Symbol(res)]: [TLSWrap],
      [Symbol(verified)]: true,
      [Symbol(pendingSession)]: null,
      [Symbol(async_id_symbol)]: 4,
      [Symbol(kHandle)]: [TLSWrap],
      [Symbol(lastWriteQueueSize)]: 0,
      [Symbol(timeout)]: null,
      [Symbol(kBuffer)]: null,
      [Symbol(kBufferCb)]: null,
      [Symbol(kBufferGen)]: null,
      [Symbol(kCapture)]: false,
      [Symbol(kSetNoDelay)]: false,
      [Symbol(kSetKeepAlive)]: false,
      [Symbol(kSetKeepAliveInitialDelay)]: 0,
      [Symbol(kBytesRead)]: 0,
      [Symbol(kBytesWritten)]: 0,
      [Symbol(connect-options)]: [Object]
    },
    _header: 'POST /api/v3/enqueueTask HTTP/1.1\r\n' +
      'Accept: application/json, text/plain, */*\r\n' +
      'Content-Type: application/json\r\n' +
      'Cookie: token_v2=***; file_token=***\r\n' +
      'User-Agent: axios/0.21.4\r\n' +
      'Content-Length: 2[12](https://github.com/TomTruyen/notion-backups/actions/runs/11086489252/job/30804081343#step:6:13)\r\n' +
      'Host: www.notion.so\r\n' +
      'Connection: close\r\n' +
      '\r\n',
    _keepAliveTimeout: 0,
    _onPendingData: [Function: nop],
    agent: Agent {
      _events: [Object: null prototype],
      _eventsCount: 2,
      _maxListeners: undefined,
      defaultPort: 443,
      protocol: 'https:',
      options: [Object: null prototype],
      requests: [Object: null prototype] {},
      sockets: [Object: null prototype],
      freeSockets: [Object: null prototype] {},
      keepAliveMsecs: 1000,
      keepAlive: false,
      maxSockets: Infinity,
      maxFreeSockets: 256,
      scheduling: 'lifo',
      maxTotalSockets: Infinity,
      totalSocketCount: 1,
      maxCachedSessions: 100,
      _sessionCache: [Object],
      [Symbol(kCapture)]: false
    },
    socketPath: undefined,
    method: 'POST',
    maxHeaderSize: undefined,
    insecureHTTPParser: undefined,
    joinDuplicateHeaders: undefined,
    path: '/api/v3/enqueueTask',
    _ended: true,
    res: IncomingMessage {
      _readableState: [ReadableState],
      _events: [Object: null prototype],
      _eventsCount: 3,
      _maxListeners: undefined,
      socket: [TLSSocket],
      httpVersionMajor: 1,
      httpVersionMinor: 1,
      httpVersion: '1.1',
      complete: true,
      rawHeaders: [Array],
      rawTrailers: [],
      joinDuplicateHeaders: undefined,
      aborted: false,
      upgrade: false,
      url: '',
      method: null,
      statusCode: 400,
      statusMessage: 'Bad Request',
      client: [TLSSocket],
      _consuming: false,
      _dumped: false,
      req: [Circular *1],
      responseUrl: 'https://www.notion.so/api/v3/enqueueTask',
      redirects: [],
      [Symbol(kCapture)]: false,
      [Symbol(kHeaders)]: [Object],
      [Symbol(kHeadersCount)]: 52,
      [Symbol(kTrailers)]: null,
      [Symbol(kTrailersCount)]: 0
    },
    aborted: false,
    timeoutCb: null,
    upgradeOrConnect: false,
    parser: null,
    maxHeadersCount: null,
    reusedSocket: false,
    host: 'www.notion.so',
    protocol: 'https:',
    _redirectable: Writable {
      _writableState: [WritableState],
      _events: [Object: null prototype],
      _eventsCount: 2,
      _maxListeners: undefined,
      _options: [Object],
      _ended: true,
      _ending: true,
      _redirectCount: 0,
      _redirects: [],
      _requestBodyLength: 212,
      _requestBodyBuffers: [],
      _onNativeResponse: [Function (anonymous)],
      _currentRequest: [Circular *1],
      _currentUrl: 'https://www.notion.so/api/v3/enqueueTask',
      [Symbol(kCapture)]: false
    },
    [Symbol(kCapture)]: false,
    [Symbol(kBytesWritten)]: 0,
    [Symbol(kNeedDrain)]: false,
    [Symbol(corked)]: 0,
    [Symbol(kOutHeaders)]: [Object: null prototype] {
      accept: [Array],
      'content-type': [Array],
      cookie: [Array],
      'user-agent': [Array],
      'content-length': [Array],
      host: [Array]
    },
    [Symbol(errored)]: null,
    [Symbol(kHighWaterMark)]: 16384,
    [Symbol(kRejectNonStandardBodyWrites)]: false,
    [Symbol(kUniqueHeaders)]: null
  },
  response: {
    status: 400,
    statusText: 'Bad Request',
    headers: {
      date: 'Sat, 28 Sep 2024 19:33:58 GMT',
      'content-type': 'application/json; charset=utf-8',
      'content-length': '186',
      connection: 'close',
      'cf-ray': '8ca62b0d0bd8fae7-SJC',
      'cf-cache-status': 'DYNAMIC',
      etag: 'W/"ba-5IrcMiVsTqaCpPKHhY3HnH3fYSM"',
      'set-cookie': [Array],
      'strict-transport-security': 'max-age=31536000; includeSubDomains; preload',
      vary: 'Accept-Encoding',
      'content-security-policy': "default-src 'none'",
      'referrer-policy': 'strict-origin-when-cross-origin',
      'server-timing': 'r;dur=998',
      'x-content-type-options': 'nosniff',
      'x-dns-prefetch-control': 'off',
      'x-download-options': 'noopen',
      'x-frame-options': 'SAMEORIGIN',
      'x-notion-request-id': 'd1de[13](https://github.com/TomTruyen/notion-backups/actions/runs/11086489252/job/30804081343#step:6:14)ce-2861-4d2c-8834-df7f89e3d00b',
      'x-permitted-cross-domain-policies': 'none',
      'x-xss-protection': '0',
      server: 'cloudflare',
      'alt-svc': 'h3=":443"; ma=86400'
    },
    config: {
      url: 'enqueueTask',
      method: 'post',
      data: '{"task":{"eventName":"exportSpace","request":{"spaceId":"***","exportOptions":{"exportType":"markdown","timeZone":"America/New_York","locale":"en"},"shouldExportComments":false}}}',
      headers: [Object],
      baseURL: 'https://www.notion.so/api/v3',
      transformRequest: [Array],
      transformResponse: [Array],
      timeout: 0,
      adapter: [Function: httpAdapter],
      xsrfCookieName: 'XSRF-TOKEN',
      xsrfHeaderName: 'X-XSRF-TOKEN',
      maxContentLength: -1,
      maxBodyLength: -1,
      validateStatus: [Function: validateStatus],
      transitional: [Object]
    },
    request: <ref *1> ClientRequest {
      _events: [Object: null prototype],
      _eventsCount: 7,
      _maxListeners: undefined,
      outputData: [],
      outputSize: 0,
      writable: true,
      destroyed: false,
      _last: true,
      chunkedEncoding: false,
      shouldKeepAlive: false,
      maxRequestsOnConnectionReached: false,
      _defaultKeepAlive: true,
      useChunkedEncodingByDefault: true,
      sendDate: false,
      _removedConnection: false,
      _removedContLen: false,
      _removedTE: false,
      strictContentLength: false,
      _contentLength: 212,
      _hasBody: true,
      _trailer: '',
      finished: true,
      _headerSent: true,
      _closed: false,
      socket: [TLSSocket],
      _header: 'POST /api/v3/enqueueTask HTTP/1.1\r\n' +
        'Accept: application/json, text/plain, */*\r\n' +
        'Content-Type: application/json\r\n' +
        'Cookie: token_v2=***; file_token=***\r\n' +
        'User-Agent: axios/0.21.4\r\n' +
        'Content-Length: 212\r\n' +
        'Host: www.notion.so\r\n' +
        'Connection: close\r\n' +
        '\r\n',
      _keepAliveTimeout: 0,
      _onPendingData: [Function: nop],
      agent: [Agent],
      socketPath: undefined,
      method: 'POST',
      maxHeaderSize: undefined,
      insecureHTTPParser: undefined,
      joinDuplicateHeaders: undefined,
      path: '/api/v3/enqueueTask',
      _ended: true,
      res: [IncomingMessage],
      aborted: false,
      timeoutCb: null,
      upgradeOrConnect: false,
      parser: null,
      maxHeadersCount: null,
      reusedSocket: false,
      host: 'www.notion.so',
      protocol: 'https:',
      _redirectable: [Writable],
      [Symbol(kCapture)]: false,
      [Symbol(kBytesWritten)]: 0,
      [Symbol(kNeedDrain)]: false,
      [Symbol(corked)]: 0,
      [Symbol(kOutHeaders)]: [Object: null prototype],
      [Symbol(errored)]: null,
      [Symbol(kHighWaterMark)]: [16](https://github.com/TomTruyen/notion-backups/actions/runs/11086489252/job/30804081343#step:6:17)384,
      [Symbol(kRejectNonStandardBodyWrites)]: false,
      [Symbol(kUniqueHeaders)]: null
    },
    data: {
      errorId: 'a7aed68a-af2e-4969-81dd-f8c589380c95',
      name: 'DecryptionError',
      debugMessage: 'Could not decrypt due to missing decryption metadata!',
      message: 'Something went wrong. (400)'
    }
  },
  isAxiosError: true,
  toJSON: [Function: toJSON]
}
dannyob commented 1 month ago

I hit this error, but it was due, I think to my cookie environment variables being misconfigured.

darobin commented 1 month ago

Yeah, Notion changes behaviour constantly without warning. This kind of error usually goes away if you set up your cookie info again.

PS: note that I'm no longer using Notion and so not maintaining this. I'll apply PRs, if any.