launchdarkly/ld-find-code-refs

Extinctions scan fails for large file diffs

Closed this issue · 4 comments

ffluk3 commented

When running ld-find-code-refs, we see the following error:

panic: runtime error: index out of range [65533] with length 55989

goroutine 1 [running]:
github.com/sergi/go-diff/diffmatchpatch.(*DiffMatchPatch).DiffCharsToLines(0xc000fe4620?, {0xc00189e930, 0x1, 0x11000?}, {0xc00de3c000, 0xdab5, 0x11000?})
	/tmp/project-releaser/project/vendor/github.com/sergi/go-diff/diffmatchpatch/diff.go:452 +0x2bb
github.com/go-git/go-git/v5/utils/diff.DoWithTimeout({0xc00b036000?, 0x0?}, {0xc00ca1c000?, 0x800?}, 0x7f453cc8f108?)
	/tmp/project-releaser/project/vendor/github.com/go-git/go-git/v5/utils/diff/diff.go:37 +0x11d
github.com/go-git/go-git/v5/utils/diff.Do(...)
	/tmp/project-releaser/project/vendor/github.com/go-git/go-git/v5/utils/diff/diff.go:22
github.com/go-git/go-git/v5/plumbing/object.filePatchWithContext({0xbdad68, 0xc00013c000}, 0xc00706f200)
	/tmp/project-releaser/project/vendor/github.com/go-git/go-git/v5/plumbing/object/patch.go:68 +0x192
github.com/go-git/go-git/v5/plumbing/object.getPatchContext({0xbdad68, 0xc00013c000}, {0x0, 0x0}, {0xc00195adc0, 0x57, 0x0?})
	/tmp/project-releaser/project/vendor/github.com/go-git/go-git/v5/plumbing/object/patch.go:38 +0xf4
github.com/go-git/go-git/v5/plumbing/object.Changes.PatchContext(...)
	/tmp/project-releaser/project/vendor/github.com/go-git/go-git/v5/plumbing/object/change.go:158
github.com/launchdarkly/ld-find-code-refs/internal/git.Client.FindExtinctions({{0x7ffccf09be80, 0x5}, {0xc00013de88, 0x8}, {0xc0001258f0, 0x28}, 0x188209ab5b0}, {{0x7ffccf09bd4b, 0x7}, {0x0, ...}, ...}, ...)
	/tmp/project-releaser/project/internal/git/git.go:264 +0x54e
github.com/launchdarkly/ld-find-code-refs/coderefs.runExtinctions({{0x7ffccf09bd18, 0x28}, {0x7ffccf09bd97, 0x1c}, {0x0, 0x0}, {0x0, 0x0}, {0x7ffccf09be09, 0x7}, ...}, ...)
	/tmp/project-releaser/project/coderefs/coderefs.go:183 +0x745
github.com/launchdarkly/ld-find-code-refs/coderefs.Run({{0x7ffccf09bd18, 0x28}, {0x7ffccf09bd97, 0x1c}, {0x0, 0x0}, {0x0, 0x0}, {0x7ffccf09be09, 0x7}, ...}, ...)
	/tmp/project-releaser/project/coderefs/coderefs.go:75 +0x9db
main.glob..func3(0xf9e6c0?, {0xaddcdf?, 0x11?, 0x11?})
	/tmp/project-releaser/project/cmd/ld-find-code-refs/main.go:83 +0x145
github.com/spf13/cobra.(*Command).execute(0xf9e6c0, {0xc00012c010, 0x11, 0x11})
	/tmp/project-releaser/project/vendor/github.com/spf13/cobra/command.go:916 +0x862
github.com/spf13/cobra.(*Command).ExecuteC(0xf9e6c0)
	/tmp/project-releaser/project/vendor/github.com/spf13/cobra/command.go:1044 +0x3bc
github.com/spf13/cobra.(*Command).Execute(...)
	/tmp/project-releaser/project/vendor/github.com/spf13/cobra/command.go:968
main.main()
	/tmp/project-releaser/project/cmd/ld-find-code-refs/main.go:97 +0x9f

Exited with code exit status 2

This appears to be related to this bug in go-diff, so a version bump might suffice for now (though it's worth noting that a second PR is out for other fixes related to this)

@ffluk3 sorry to hear you are running into this issue.

Can you confirm which version of ld-find-code-refs you are using?

I just opened a support ticket and was pointed to this issue. I'm also seeing this with a new action we created for a repo.

    - name: LaunchDarkly Code References
      uses: launchdarkly/find-code-references@v2.11.2
ffluk3 commented

It looks like a few weeks ago the upstream go-diff version fixed issues which could prevent upgrading. I can send over a version bump PR!

ffluk3 commented

@jazanne we were seeing it on v2.10.0, and it makes sense we would even see it on latest until we bump the downstream library to take in the change. PR is up if y'all are willing to take it in!