launchdarkly / ld-find-code-refs

Build tool for automatically sending feature flag code references to LaunchDarkly
https://launchdarkly.com
Other
46 stars 34 forks source link

Runtime error: slice bounds out of range #223

Closed bdarcet closed 2 years ago

bdarcet commented 2 years ago

Hello,

I'm using the github action pipeline, and it's been working fine until recently, when it started failing with this error:

warning: debug option `false' unknown; try LD_DEBUG=help
INFO: 2022/02/25 08:31:36 github-actions.go:30: Setting GitHub action env vars
INFO: 2022/02/25 08:31:36 coderefs.go:28: absolute directory path: /github/workspace
INFO: 2022/02/25 08:31:36 git.go:47: git branch: fix/ld-check
panic: runtime error: slice bounds out of range [:500] with capacity 320

goroutine 9878 [running]:
github.com/launchdarkly/ld-find-code-refs/search.truncateLine(...)
    /tmp/project-releaser/project/search/search.go:36
github.com/launchdarkly/ld-find-code-refs/search.file.hunkForLine({{0xc003b26ed2, 0x20}, {0xc004b0e000, 0x195d, 0x1e00}}, {0xc000024174, 0x7}, {0xc0001e9d40, 0x18}, 0xb4b, ...)
    /tmp/project-releaser/project/search/search.go:70 +0x4fe
github.com/launchdarkly/ld-find-code-refs/search.file.aggregateHunksForFlag({{0xc003b26ed2, 0x20}, {0xc004b0e000, 0x195d, 0x1e00}}, {0xc000024174, 0x7}, {0xc0001e9d40, 0x18}, {{0xc000198080, ...}, ...}, ...)
    /tmp/project-releaser/project/search/search.go:91 +0x15d
github.com/launchdarkly/ld-find-code-refs/search.file.toHunks({{0xc003b26ed2, 0x20}, {0xc004b0e000, 0x195d, 0x1e00}}, {{0xc000198080, 0x6721cb, 0xc000094c00}, 0xc00019b260})
    /tmp/project-releaser/project/search/search.go:120 +0x41c
github.com/launchdarkly/ld-find-code-refs/search.processFiles.func1({{0xc003b26ed2, 0x20}, {0xc004b0e000, 0x195d, 0x1e00}})
    /tmp/project-releaser/project/search/search.go:186 +0x75
created by github.com/launchdarkly/ld-find-code-refs/search.processFiles
    /tmp/project-releaser/project/search/search.go:185 +0x2b2

This is my yml file:

on:
  push:
    branches-ignore:
      - 'dependabot/**'
name: LaunchDarkly Code References
jobs:
  launchDarklyCodeReferences:
    name: LaunchDarkly Code References
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 11
      - name: LaunchDarkly Code References
        uses: launchdarkly/find-code-references@v7
        with:
          githubToken: ${{ secrets.GITHUB_TOKEN }}
          accessToken: ${{ secrets.LD_ACCESS_TOKEN }}
          projKey: defakt

I've tried to upgrade the version but it didn't work

jazanne commented 2 years ago

@bdarcet thanks for sharing this error.

Just to clarify, when you say you upgraded the version do you mean v2.5.4? (we changed the version strategy recently)

bdarcet commented 2 years ago

@jazanne Yes exactly! I had the error with my current version (shared in the snippet). I tried to upgrade to v2.5.4, to see if it would make any difference but it didn't unfortunately.

jazanne commented 2 years ago

@bdarcet We were able to find the issue and make a fix. We plan on getting a new release tomorrow.

bdarcet commented 2 years ago

@jazanne Amazing, thanks a lot!

jazanne commented 2 years ago

@bdarcet Release is now available https://github.com/launchdarkly/find-code-references/releases/tag/v2.5.5

bdarcet commented 2 years ago

Thanks @jazanne !

Sorry to bother again, but after upgrading to 2.5.5, I'm getting this error :

  /usr/bin/docker build -t 7db2d7:4588972828cd4503a792f3a143192a8b -f "/home/runner/work/_actions/launchdarkly/find-code-references/v2.5.5/Dockerfile" "/home/runner/work/_actions/launchdarkly/find-code-references/v2.5.5"
  Sending build context to Docker daemon  11.26kB

  Step 1/7 : FROM launchdarkly/ld-find-code-refs-github-action:2.5.5
  manifest for launchdarkly/ld-find-code-refs-github-action:2.5.5 not found: manifest unknown: manifest unknown
Error: Docker build failed with exit code 1

Is the issue coming from my side ?

jazanne commented 2 years ago

@bdarcet Thanks for bringing this to our attention. I'm going to open a new issue https://github.com/launchdarkly/ld-find-code-refs/issues/228