palaniraja / blog2md

Convert Blogger & Wordpress backup blog posts to hugo compatible markdown documents
162 stars 43 forks source link

Error when Blogger draft has no title: `throw er; // Unhandled 'error' event` #38

Open levid0s opened 1 year ago

levid0s commented 1 year ago

When I ran blog2md on my Blogger export, it crashed with the following error:

PS D:\temp\blog2md> ..\node-v18.14.2-win-x64\node.exe index.js b .\blog-03-04-2023.xml ./myblog
INFO: Comments requested to be a separate .md file(m - default)
Total no. of entries found : 295
Content-posts 63
Content-Comments 180
title: "undefined"
date: 2014-08-08T01:35:00.001+03:00
draft: true
node:events:491
      throw er; // Unhandled 'error' event
      ^

Error: Input must be string
    at sanitize (D:\temp\blog2md\node_modules\sanitize-filename\index.js:41:11)
    at module.exports (D:\temp\blog2md\node_modules\sanitize-filename\index.js:54:16)
    at getFileName (D:\temp\blog2md\index.js:245:23)
    at D:\temp\blog2md\index.js:306:42
    at Array.forEach (<anonymous>)
    at D:\temp\blog2md\index.js:286:23
    at Parser.<anonymous> (D:\temp\blog2md\node_modules\xml2js\lib\parser.js:303:18)
    at Parser.emit (node:events:513:28)
    at SAXParser.onclosetag (D:\temp\blog2md\node_modules\xml2js\lib\parser.js:261:26)
    at emit (D:\temp\blog2md\node_modules\sax\lib\sax.js:624:35)
Emitted 'error' event on Parser instance at:
    at exports.Parser.Parser.parseString (D:\temp\blog2md\node_modules\xml2js\lib\parser.js:326:16)
    at Parser.parseString (D:\temp\blog2md\node_modules\xml2js\lib\parser.js:5:59)
    at D:\temp\blog2md\index.js:257:16
    at FSReqCallback.readFileAfterClose [as oncomplete] (node:internal/fs/read_file_context:68:3)

I realised this was caused by an unpublished draft from 2014 that didn't have a title configured. After adding a title on Blogger, and downloading a new .xml export, blog2md worked sucessfully.