Legit-Labs/legitify

GHA fails with panic: runtime error: invalid memory address or nil pointer dereference

ygworldr opened this issue · 1 comments

TL;DR

A simple GHA crashes with panic: runtime error: invalid memory address or nil pointer dereference.

Expected behavior

  1. The action runs successfully.
  2. A sarif report is available.

The latter point is why I am not using v0.2.6 since it appears that is not supported there. I tried, I got no report.

Observed behavior

The GHA stops with this error message:

Error: The process '/home/runner/work/_actions/Legit-Labs/legitify/main/legitify' failed with exit code 2 | stderr: panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x10[3](https://github.com/worldr/action-runner/actions/runs/5198695844/jobs/9375155007?pr=3#step:3:3)d61c]

Version

main

On which operating system are you using legitify?

Linux

Relevant log output

Legit-Labs/legitify@main
  with:
    github_token: ***
    scorecard: true
    upload_code_scanning: true
    analyze_self_only: false
    legitify_base_version: 0.2
    compile_legitify: false
Run actions/setup-node@v3
  with:
    node-version: 16
    always-auth: false
    check-latest: false
    token: ***
Found in cache @ /opt/hostedtoolcache/node/16.20.0/x64
Environment details
Run cd "$GITHUB_ACTION_PATH"
downloading legitify binary from the following release URL: https://github.com/Legit-Labs/legitify/releases/download/v0.2.6/legitify_0.2.6_linux_amd64.tar.gz
execute legitify analyze: [
  'analyze',
  '--org',
  'worldr',
  '--output-format',
  'json',
  '--output-file',
  'legitify-output.json'
]
execute legitify convert sarif: [
  'convert',
  '--input-file',
  'legitify-output.json',
  '--output-format',
  'sarif',
  '--output-file',
  'legitify-output.sarif'
]
Error: The process '/home/runner/work/_actions/Legit-Labs/legitify/main/legitify' failed with exit code 2 | stderr: panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x103d61c]

goroutine 1 [running]:
github.com/Legit-Labs/legitify/internal/outputer/formatter.ValidateOutputFormat({0x7ffc97ca1f5b, 0x5}, {0x152d50a, 0x9})
	/home/runner/work/legitify/legitify/internal/outputer/formatter/output_format.go:38 +0x5c
github.com/Legit-Labs/legitify/cmd.(*args).validateSchemeOutputOptions(0x211b460)
	/home/runner/work/legitify/legitify/cmd/common_args.go:140 +0xc5
github.com/Legit-Labs/legitify/cmd.(*args).applySchemeOutputOptions(0x0?)
	/home/runner/work/legitify/legitify/cmd/common_args.go:124 +0x1e
github.com/Legit-Labs/legitify/cmd.executeConvertCommand(0xc0004dc780?, {0x1526f55?, 0x6?, 0x6?})
	/home/runner/work/legitify/legitify/cmd/convert.go:55 +0x75
github.com/spf13/cobra.(*Command).execute(0xc0004dc780, {0xc000089620, 0x6, 0x6})
	/home/runner/go/pkg/mod/github.com/spf13/cobra@v1.5.0/command.go:872 +0x694
github.com/spf13/cobra.(*Command).ExecuteC(0x2109160)
	/home/runner/go/pkg/mod/github.com/spf13/cobra@v1.5.0/command.go:990 +0x3bd
github.com/spf13/cobra.(*Command).Execute(...)
	/home/runner/go/pkg/mod/github.com/spf13/cobra@v1.5.0/command.go:918
github.com/Legit-Labs/legitify/cmd.Execute()
	/home/runner/work/legitify/legitify/cmd/root.go:35 +0x198
main.main()
	/home/runner/work/legitify/legitify/main.go:6 +0x17

Error: Error: The process '/home/runner/work/_actions/Legit-Labs/legitify/main/legitify' failed with exit code 2
Error: Process completed with exit code 1.

Additional information

The GHA I am using:

--
name: "Run Legitify to check GH org settings."

on:  # yamllint disable-line rule:truthy
  push:
    branches: ['main']
  pull_request:
    # The branches below must be a subset of the branches above
    branches: ['main']
  schedule:
    #       ┌───────────── minute (0 - 59)
    #       │  ┌───────────── hour (0 - 23)
    #       │  │ ┌───────────── day of the month (1 - 31)
    #       │  │ │ ┌───────────── month (1 - 12 or JAN-DEC)
    #       │  │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT)
    #       │  │ │ │ │
    #       │  │ │ │ │
    #       │  │ │ │ │
    #       *  * * * *
    - cron: '0 7 * * 1-5'

jobs:
  legitify-analyze:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v3
      - name: Legitify Action
        uses: Legit-Labs/legitify@main
        with:
          github_token: ${{ secrets.LEGITIFY_PAT }}
          scorecard: true
          upload_code_scanning: true

Duplicate of #201… My apologies for the noise.