question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Book fails to open via OpenBookAsync (Regression)

See original GitHub issue

Description

I have a book that fails to open after updating this library from v3.1.2 to v3.2

My Code:

using var epubBook = EpubReader.OpenBook(filePath, BookReaderOptions);
BookReaderOptions = = new()
    {
        PackageReaderOptions = new PackageReaderOptions()
        {
            IgnoreMissingToc = true
        }
    };

Sample EPUB file

<?xml version="1.0" encoding="utf-8"?>
<package unique-identifier="fanficfare-uid" version="2.0" xmlns="http://www.idpf.org/2007/opf">
    <metadata xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:opf="http://www.idpf.org/2007/opf">
        <dc:identifier id="fanficfare-uid">fanficfare-uid:www.royalroad.com-u87585-s26294</dc:identifier>
        <dc:title id="id">He Who Fights With Monsters</dc:title>
        <dc:creator opf:role="aut">Shirtaloon (Travis Deverell)</dc:creator>
        <dc:contributor id="id-2">FanFicFare [https://github.com/JimmXinu/FanFicFare]</dc:contributor>
        <dc:language>en</dc:language>
        <dc:date opf:event="publication">2019-07-28</dc:date>
        <dc:date opf:event="creation">2022-09-17</dc:date>
        <dc:date opf:event="modification">2022-09-17</dc:date>
        <meta content="2022-09-17T00:00:30" name="calibre:timestamp" />
        <dc:description>Some description here</dc:description>
        <dc:subject>High Fantasy</dc:subject>
        <dc:subject>Last Update: 2022/09/17</dc:subject>
        <dc:subject>LitRPG</dc:subject>
        <dc:subject>Adventure</dc:subject>
        <dc:publisher>www.royalroad.com</dc:publisher>
        <dc:identifier opf:scheme="URL">https://www.royalroad.com/fiction/26294</dc:identifier>
        <dc:source>https://www.royalroad.com/fiction/26294</dc:source>
    </metadata>
    <manifest>
        <item href="toc.ncx" id="ncx" media-type="application/x-dtbncx+xml" />
        <item href="OEBPS/stylesheet.css" id="style" media-type="text/css" />
        <item href="OEBPS/title_page.xhtml" id="title_page" media-type="application/xhtml+xml" />
        <item href="OEBPS/file0001.xhtml" id="file0001" media-type="application/xhtml+xml" />
        ...
        <item href="OEBPS/file0153.xhtml" id="file0153" media-type="application/xhtml+xml" />
    </manifest>
    <spine toc="ncx">
        <itemref idref="title_page" linear="yes" />
        <itemref idref="file0001" linear="yes" />
        ...
        <itemref idref="file0153" linear="yes" />
    </spine>
</package>

I have validated all items exist and table of contents looks fine.

Stack Trace:

[18:47:11 WRN] [BookService] There was an exception when opening epub book: E:\Books\Wont Open\He_Who_Fights_With_Monsters_-_Shirtaloon.epub
System.AggregateException: One or more errors occurred. (Object reference not set to an instance of an object.)
 ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at VersOne.Epub.Internal.BookCoverReader.ReadEpub2CoverFromGuide(EpubSchema epubSchema, Dictionary`2 imageContentRefs)
   at VersOne.Epub.Internal.BookCoverReader.ReadEpub2Cover(EpubSchema epubSchema, Dictionary`2 imageContentRefs)
   at VersOne.Epub.Internal.BookCoverReader.ReadBookCover(EpubSchema epubSchema, Dictionary`2 imageContentRefs)
   at VersOne.Epub.Internal.ContentReader.ParseContentMap(EpubBookRef bookRef, ContentReaderOptions contentReaderOptions)
   at VersOne.Epub.EpubReader.<>c__DisplayClass10_0.<OpenBookAsync>b__1()
   at System.Threading.Tasks.Task`1.InnerInvoke()
   at System.Threading.Tasks.Task.<>c.<.cctor>b__272_0(Object obj)
   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
--- End of stack trace from previous location ---
   at VersOne.Epub.EpubReader.OpenBookAsync(IZipFile zipFile, String filePath, EpubReaderOptions epubReaderOptions)
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
   at System.Threading.Tasks.Task`1.get_Result()
   at VersOne.Epub.EpubReader.OpenBook(String filePath, EpubReaderOptions epubReaderOptions)

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
majora2007commented, Sep 19, 2022

Wow, extremely fast. I’ll take a look and validate and report back to you after work today.

0reactions
majora2007commented, Sep 19, 2022

Okay, then looks like I have enough time. Well, thank you again for the library and especially now that you’re back and improving it. My users have been extremely happy with the recent changes you’ve been making.

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found