Skip to content

NPE while getting Kustomization inventory #3902

@chanwit

Description

@chanwit

given this kustomization

apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
metadata:
  creationTimestamp: "2023-07-31T15:05:53Z"
  finalizers:
  - finalizers.fluxcd.io
  generation: 1
  labels:
    kustomize.toolkit.fluxcd.io/name: flux-system
    kustomize.toolkit.fluxcd.io/namespace: flux-system
  name: rbac-secrets-good-practices
  namespace: flux-system
  resourceVersion: "9437086"
  uid: f3780853-bf47-4a3b-b5e3-f029623e8595
spec:
  force: false
  interval: 1m0s
  path: ./goodpractices/kubernetes/rbac/secrets
  prune: true
  sourceRef:
    kind: GitRepository
    name: policy-library
status:
  conditions:
  - lastTransitionTime: "2023-07-31T15:05:54Z"
    message: Source is not ready, artifact not found
    observedGeneration: 1
    reason: ArtifactFailed
    status: "False"
    type: Ready
  observedGeneration: -1

when getting inventory
then npe is thrown due to kustomization without enteries

2023/07/31 15:09:35 http: panic serving 127.0.0.1:56444: runtime error: invalid memory address or nil pointer dereference
goroutine 23912 [running]:
net/http.(*conn).serve.func1()
	/opt/homebrew/Cellar/go/1.20.2/libexec/src/net/http/server.go:1854 +0xbf
panic({0x346fca0, 0x61e4e10})
	/opt/homebrew/Cellar/go/1.20.2/libexec/src/runtime/panic.go:890 +0x263
github.com/weaveworks/weave-gitops/core/server.(*coreServer).getKustomizationInventory(0xc001204780, {0x427ff68?, 0xc002826780}, {0xc0010e8068, 0xa}, {0x4295480, 0xc000293490}, {0xc0010e8017, 0x1b}, {0xc0010e803d, ...}, ...)
	/github.com/weaveworks/weave-gitops-enterprise/vendor/github.com/weaveworks/weave-gitops/core/server/inventory.go:74 +0x178
github.com/weaveworks/weave-gitops/core/server.(*coreServer).GetInventory(0xc001204780, {0x427ff68, 0xc002826780}, 0xc005c80000)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions