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.

HtmlDocument.ParseDocumentAsync results in ArgumentOutOfRangeException

See original GitHub issue

Bug Report

Prerequisites

  • Can you reproduce the problem in a MWE?
  • Are you running the latest version of AngleSharp?
  • Did you check the FAQs to see if that helps you?
  • Are you reporting to the correct repository? (there are multiple AngleSharp libraries, e.g., AngleSharp.Css for CSS support)
  • Did you perform a search in the issues? Yes, #452 But was nothing wrong.

For more information, see the CONTRIBUTING guide.

Description

Exception when parsing a ‘document’.

System.ArgumentOutOfRangeException
  HResult=0x80131502
  Message=Index must be within the bounds of the List. (Parameter 'index')
  Source=System.Private.CoreLib
  StackTrace:
   at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
   at System.Collections.Generic.List`1.Insert(Int32 index, T item)
   at AngleSharp.Html.Parser.HtmlDomBuilder.HeisenbergAlgorithm(HtmlTagToken tag)
   at AngleSharp.Html.Parser.HtmlDomBuilder.InBodyEndTag(HtmlTagToken tag)
   at AngleSharp.Html.Parser.HtmlDomBuilder.InCell(HtmlToken token)
   at AngleSharp.Html.Parser.HtmlDomBuilder.<ParseAsync>d__23.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
   at AngleSharp.Html.Parser.HtmlParser.<ParseAsync>d__28.MoveNext()

Steps to Reproduce

await new HtmlParser().ParseDocumentAsync(await new HttpClient().GetStringAsync("http://www.artfiles.org/netlib.org/blast/blast-nearterm"));

Expected behavior:

That it handles the input without exception.

Actual behavior:

Something internally goes wrong.

Environment details:

.NET Core 3.1 on Windows 10 Pro 2004

Possible Solution

It looks like it must be something with list management. Hopefully it’s clear and quick to fix.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
KoalaBear84commented, Jul 15, 2020

Thanks, ‘verified’! 👍

0reactions
FlorianRapplcommented, Jul 14, 2020

Fix available in the preview and in devel.

Read more comments on GitHub >

github_iconTop Results From Across the Web

HtmlAgilityPack ArgumentOutOfRangeException
Currently, when I run the above, I get an ArgumentOutOfRangeException at string test = doc.DocumentNode.Element("html").Element("body").Element( ...
Read more >

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