[Bug] [CLI] Kyverno CLI 1.19.0 `apply` fails on Kind: List resources
Author: tom-dierckx-klarrioCreated Aug 26, 2026Updated Sep 18, 2026
Labelsbugtype:cliend usertriage
Kyverno CLI Version
1.19.0
Description
This is for CLI version 1.19.0 not 1.18.
Version: 1.19.0
Time: 2026-08-20T08:52:56Z
Git commit ID: ee97ce09538b09b6f1b03853cc41a62654d6a58fWe see errors when processing List objects when using the kyverno apply command with any policy it fails on loading the resources with this exception:
panic: *unstructured.Unstructured is not a list: no Items field in this object
goroutine 1 [running]:
k8s.io/client-go/dynamic/fake.NewSimpleDynamicClientWithCustomListKinds(0xbe6bd08f570, 0xbe6c0512670, {0xbe6bef4f2e0, 0x1, 0x2?})
/home/runner/go/pkg/mod/k8s.io/[email protected]/dynamic/fake/simple.go:110 +0xa37
github.com/kyverno/kyverno/pkg/clients/dclient.NewFakeClient(0xbe6bd08f500, 0xbe6c0512670, {0xbe6c0511f18, 0x1, 0x1})
/home/runner/work/kyverno/kyverno/pkg/clients/dclient/fake.go:48 +0x44d
github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/commands/apply.createFakeClientFromResources({0xbe6bd304750, 0x1, 0xbe6bcc13400?}, {0x0, 0x0, 0xbe6bd83cc40?}, {0x0, 0x0, 0xbe6be452510?})
/home/runner/work/kyverno/kyverno/cmd/cli/kubectl-kyverno/commands/apply/command.go:1336 +0xbab
github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/commands/apply.(*ApplyCommandConfig).applyCommandHelper(0xbe6bcc13400, {0xc84a840, 0xbe6bc93c068})
/home/runner/work/kyverno/kyverno/cmd/cli/kubectl-kyverno/commands/apply/command.go:365 +0x262b
github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/commands/apply.Command.func1(0xbe6bd640908, {0xbe6bd300720, 0x1, 0x2})
/home/runner/work/kyverno/kyverno/cmd/cli/kubectl-kyverno/commands/apply/command.go:154 +0x145
github.com/spf13/cobra.(*Command).execute(0xbe6bd640908, {0xbe6bd300700, 0x2, 0x2})
/home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:1015 +0xb14
github.com/spf13/cobra.(*Command).ExecuteC(0xbe6bd640608)
/home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:1148 +0x465
github.com/spf13/cobra.(*Command).Execute(...)
/home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:1071
main.main()
/home/runner/work/kyverno/kyverno/cmd/cli/kubectl-kyverno/main.go:21 +0x89When using version 1.18.2 this works. It seems to be related to https://github.com/kyverno/kyverno/pull/15846.
Steps to reproduce
Run kyverno apply of version 1.19.0 with a --resource containing a kubernetes kind: List.
Setup script of local test
#!/bin/bash
# create resource
cat > /tmp/list.yaml << EOF
apiVersion: v1
kind: List
items:
- apiVersion: v1
kind: Service
metadata:
name: list-service-test
spec:
ports:
- protocol: TCP
port: 80
selector:
app: list-deployment-test
- apiVersion: apps/v1
kind: Deployment
metadata:
name: list-deployment-test
labels:
app: list-deployment-test
spec:
replicas: 1
selector:
matchLabels:
app: list-deployment-test
template:
metadata:
labels:
app: list-deployment-test
spec:
containers:
- name: nginx
image: nginx
EOF
# create (random) policy
cat > /tmp/policy.yaml << EOF
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: require-labels
annotations:
policies.kyverno.io/title: Require Labels
policies.kyverno.io/category: Best Practices
policies.kyverno.io/minversion: 1.6.0
policies.kyverno.io/severity: medium
policies.kyverno.io/subject: Pod, Label
policies.kyverno.io/description: Define and use labels that identify semantic attributes of your application or Deployment. A common set of labels allows tools to work collaboratively, describing objects in a common manner that all tools can understand. The recommended labels describe applications in a way that can be queried. This policy validates that the is specified with some value.
spec:
validationFailureAction: Audit
background: true
rules:
- name: check-for-labels
match:
any:
- resources:
kinds:
- Pod
validate:
message: The label is required.
pattern:
metadata:
labels:
testlabel: "?*"
EOF
kyverno apply /tmp/policy.yaml --resource=/tmp/list.yamlExpected behavior
No panic exception when using a kind: List object as resource
Screenshots
No response
Kyverno logs
panic: *unstructured.Unstructured is not a list: no Items field in this object
goroutine 1 [running]:
k8s.io/client-go/dynamic/fake.NewSimpleDynamicClientWithCustomListKinds(0xbe6bd08f570, 0xbe6c0512670, {0xbe6bef4f2e0, 0x1, 0x2?})
/home/runner/go/pkg/mod/k8s.io/[email protected]/dynamic/fake/simple.go:110 +0xa37
github.com/kyverno/kyverno/pkg/clients/dclient.NewFakeClient(0xbe6bd08f500, 0xbe6c0512670, {0xbe6c0511f18, 0x1, 0x1})
/home/runner/work/kyverno/kyverno/pkg/clients/dclient/fake.go:48 +0x44d
github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/commands/apply.createFakeClientFromResources({0xbe6bd304750, 0x1, 0xbe6bcc13400?}, {0x0, 0x0, 0xbe6bd83cc40?}, {0x0, 0x0, 0xbe6be452510?})
/home/runner/work/kyverno/kyverno/cmd/cli/kubectl-kyverno/commands/apply/command.go:1336 +0xbab
github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/commands/apply.(*ApplyCommandConfig).applyCommandHelper(0xbe6bcc13400, {0xc84a840, 0xbe6bc93c068})
/home/runner/work/kyverno/kyverno/cmd/cli/kubectl-kyverno/commands/apply/command.go:365 +0x262b
github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/commands/apply.Command.func1(0xbe6bd640908, {0xbe6bd300720, 0x1, 0x2})
/home/runner/work/kyverno/kyverno/cmd/cli/kubectl-kyverno/commands/apply/command.go:154 +0x145
github.com/spf13/cobra.(*Command).execute(0xbe6bd640908, {0xbe6bd300700, 0x2, 0x2})
/home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:1015 +0xb14
github.com/spf13/cobra.(*Command).ExecuteC(0xbe6bd640608)
/home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:1148 +0x465
github.com/spf13/cobra.(*Command).Execute(...)
/home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:1071
main.main()
/home/runner/work/kyverno/kyverno/cmd/cli/kubectl-kyverno/main.go:21 +0x89Slack discussion
No response
Troubleshooting
- I have read and followed the troubleshooting guide.
- I have searched other issues in this repository and mine is not recorded.
Source: kyverno/kyverno