Skip to content

panic when analyzing with nats audit #684

@joeriddles

Description

@joeriddles

Running nats audit analyze <archive> panics.

Appears to panic on this line:

if nfo.Cluster.Leader != serverName {


NATS env:

❯ nats-server --version
nats-server: v2.11.7

❯ nats --version
v0.2.4-0.20250519092013-0f6baae0e824

Server config:

jetstream: {}

http_port: 8222 

accounts: {
  $SYS: {
    users: [{user: sys, password: pass}]
  }
}

Running gather:

❯ nats --user=sys --password=pass audit gather
11:37:12 Broadcasting PING to discover servers... (this may take a few seconds)
11:37:12 Discovered server 'NBKYUFKIATQP2B7ORGKI6TWNQI45DJFBEMCVR5EY3NQ62JBHJZLRI2XR' (NBKYUFKIATQP2B7ORGKI6TWNQI45DJFBEMCVR5EY3NQ62JBHJZLRI2XR)
11:37:17 Discovered 1 servers
11:37:17 Broadcasting PING to discover accounts...
11:37:17 Discovered 2 accounts on server NBKYUFKIATQP2B7ORGKI6TWNQI45DJFBEMCVR5EY3NQ62JBHJZLRI2XR
11:37:17 Discovered system account name: $SYS
11:37:17 Discovered 2 accounts over 1 servers
11:37:17 Querying 9 endpoints on 1 known servers...
11:37:17 Captured 15 endpoint responses from 1 servers
11:37:17 Capturing 8 profiles on 1 known servers...
11:37:22 Captured 8 server profiles from 1 servers
11:37:22 Querying 5 endpoints for 2 known accounts...
11:37:22 Received an error from server NBKYUFKIATQP2B7ORGKI6TWNQI45DJFBEMCVR5EY3NQ62JBHJZLRI2XR: (0) account "$SYS" not jetstream enabled
11:37:22 Captured 9 endpoint responses from 2 accounts
11:37:22 Gathering streams data...
11:37:22 Discovered stream scrape in account $G
11:37:22 Discovered 1 streams in account $G
Archive created at: /var/folders/q3/sxmzn9xs6r90xcfzr3g5ch2m0000gn/T/audit-archive-1754501832.zip

Running analyze:

❯ nats audit analyze /var/folders/q3/sxmzn9xs6r90xcfzr3g5ch2m0000gn/T/audit-archive-1754501832.zip
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x28 pc=0x100fe7dc8]

goroutine 1 [running]:
github.com/nats-io/jsm.go/audit.checkConsumerMetadataMonitoring.func1(0x140002c9180?)
        /Users/joe/go/pkg/mod/github.com/nats-io/jsm.go@v0.2.3/audit/jetstream_checks.go:391 +0xc8
github.com/nats-io/jsm.go/audit/archive.ForEachTaggedArtifact[...](0x1400001a540, {0x14000531478, 0x101592430?, 0x10165ea60?}, 0x14000531430?)
        /Users/joe/go/pkg/mod/github.com/nats-io/jsm.go@v0.2.3/audit/archive/reader.go:523 +0x320
github.com/nats-io/jsm.go/audit.checkConsumerMetadataMonitoring(0x10129acfc?, 0x1400001a540, 0x140003f0d80, {0x10186f4c0, 0x140005a37d0})
        /Users/joe/go/pkg/mod/github.com/nats-io/jsm.go@v0.2.3/audit/jetstream_checks.go:389 +0x51c
github.com/nats-io/jsm.go/audit.runCheck(0x1400030b860, 0x1400001a540, 0x5, {0x10186f4c0, 0x140005a37d0})
        /Users/joe/go/pkg/mod/github.com/nats-io/jsm.go@v0.2.3/audit/checks.go:248 +0x84
github.com/nats-io/jsm.go/audit.(*CheckCollection).Run.func1(0x1400030b860)
        /Users/joe/go/pkg/mod/github.com/nats-io/jsm.go@v0.2.3/audit/checks.go:318 +0x1e4
github.com/nats-io/jsm.go/audit.(*CheckCollection).EachCheck(0x1400030ae60, 0x140005318b8)
        /Users/joe/go/pkg/mod/github.com/nats-io/jsm.go@v0.2.3/audit/checks.go:277 +0x2ec
github.com/nats-io/jsm.go/audit.(*CheckCollection).Run(0x1400030ae60, 0x1400001a540, 0x5, {0x10186f4c0, 0x140005a37d0})
        /Users/joe/go/pkg/mod/github.com/nats-io/jsm.go@v0.2.3/audit/checks.go:307 +0x2e4
github.com/nats-io/natscli/cli.(*auditAnalyzeCmd).analyze(0x1400023ce00, 0x100ebc7cc?)
        /Users/joe/source/nats/natscli/cli/audit_analyze_command.go:103 +0x210
github.com/choria-io/fisk.(*actionMixin).applyActions(...)
        /Users/joe/go/pkg/mod/github.com/choria-io/fisk@v0.7.1/actions.go:28
github.com/choria-io/fisk.(*Application).applyActions(0x14000332500?, 0x140000f4480)
        /Users/joe/go/pkg/mod/github.com/choria-io/fisk@v0.7.1/app.go:827 +0xf0
github.com/choria-io/fisk.(*Application).execute(0x14000332500, 0x140000f4480, {0x1400044c300, 0x2, 0x2})
        /Users/joe/go/pkg/mod/github.com/choria-io/fisk@v0.7.1/app.go:613 +0x50
github.com/choria-io/fisk.(*Application).Parse(0x14000332500, {0x14000032050?, 0x1400031de60?, 0x28?})
        /Users/joe/go/pkg/mod/github.com/choria-io/fisk@v0.7.1/app.go:276 +0x108
github.com/choria-io/fisk.(*Application).MustParseWithUsage(0x14000332500, {0x14000032050, 0x3, 0x3})
        /Users/joe/go/pkg/mod/github.com/choria-io/fisk@v0.7.1/app.go:893 +0x34
main.main()
        /Users/joe/source/nats/natscli/nats/main.go:84 +0x2a38

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions