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.

TextContainer GetLocation Throws Exception Occasionally

See original GitHub issue

Describe the bug On occasion there the RulesEngine throws an exception for certain files when trying to determine match locations from the TextContainer.cs file indicated. The issue appears to be a conditional that allows there to be an uneven number of items between the LineEnds and LineStarts lists culminating in a failure in the GetLocation method on line 218. The solution appears to be correcting the boundary limit in the constructor to include ‘<=’ on line 35.

To Reproduce Source code to reproduce will vary…was primarily python if that helps. The behavior interestingly was seen while using the NuGet model but not the commandLine one -not sure why but time is limited to investigate but it is also not consistent for reasons unknown i.e. sometimes it doesn’t throw an exception.

Expected behavior Complete analysis for source without throwing an exception

Code Section File: …\ApplicationInspector-main\RulesEngine\TextContainer.cs Class & Method: TextContainer : TextContainer Line: 35

while (pos > -1)
{
           **if (pos > 0 && pos + 1 < FullContent.Length)**
           {
                    LineStarts.Add(pos + 1);
           }
           pos = FullContent.IndexOf('\n', pos + 1);
     
           if (LineEnds.Count < LineStarts.Count)
           {
                LineEnds.Add(FullContent.Length - 1);
           }
}

and in method GetLocation line 218 where the indexing exception gets thrown

result.Column = index - LineStarts[i];

Screenshots appinsbug-txtcontainer

Additional context Add any other context about the problem here.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
guyacostacommented, Nov 8, 2021

Looks fixed!

1reaction
gfscommented, Nov 3, 2021

You won’t have access to the Microsoft repo so you need to make a fork and then make a branch on that fork and then open a PR from that branch.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Locator
Locators are the central piece of Playwright's auto-waiting and retry-ability. In a nutshell, locators represent a way to find element(s) on the page...
Read more >
How to Use Touch Actions in Appium: Swipe Tap Touch
Press by using an element and duration (in seconds); Press by using x,y coordinates, and duration (in seconds); Horizontal swipe by using the ......
Read more >
Geocoding Service | Maps JavaScript API
"ERROR" indicates that the request timed out or there was a problem contacting the Google servers. The request may succeed if you try...
Read more >
java - Using Try Catch Exception handling or explicit checks
Here, I throw my own custom exception from utility methods if the session is closed (invalid) or if the location is null.
Read more >
Common Nginx Connection Errors
In this tutorial, you will learn about what a browser connection error means for your Nginx web server and the various steps you...
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