What's happening
Opening any namespaced Policy's detail page in the Kyverno plugin shows an empty "Associated Report Results" table, even when matching PolicyReport results genuinely exist for it.
Why
AssociatedReportsSection in PolicyViewer.tsx matches report results by comparing the bare policy name:
for (const report of policyReports) {
for (const result of report.results) {
if (result.policy === policyName) {
matchingResults.push({ ... });
}
}
}
Kyverno prefixes namespaced-policy results as <namespace>/<name> — this is already the convention bucketReportResults/usePolicyResultCounts rely on elsewhere in this plugin (policyResultBucket.ts). AssociatedReportsSection never applied it, so for a namespaced policy the comparison is always "default/require-labels" === "require-labels", which is never true.
Separately, the two report lists (policyReports, clusterPolicyReports) are scanned independently, but a ClusterPolicy's results can land in either report type depending on whether the matched resource is namespaced or cluster-scoped, so results could be missed even once the key comparison is fixed.
Fix
Reuse the existing <namespace>/<name> (or bare <name> for cluster-scoped) key convention from policyResultBucket.ts, and merge both report lists before filtering.
I have this implemented and tested locally, opening a PR now.
What's happening
Opening any namespaced
Policy's detail page in the Kyverno plugin shows an empty "Associated Report Results" table, even when matchingPolicyReportresults genuinely exist for it.Why
AssociatedReportsSectioninPolicyViewer.tsxmatches report results by comparing the bare policy name:Kyverno prefixes namespaced-policy results as
<namespace>/<name>— this is already the conventionbucketReportResults/usePolicyResultCountsrely on elsewhere in this plugin (policyResultBucket.ts).AssociatedReportsSectionnever applied it, so for a namespaced policy the comparison is always"default/require-labels" === "require-labels", which is never true.Separately, the two report lists (
policyReports,clusterPolicyReports) are scanned independently, but aClusterPolicy's results can land in either report type depending on whether the matched resource is namespaced or cluster-scoped, so results could be missed even once the key comparison is fixed.Fix
Reuse the existing
<namespace>/<name>(or bare<name>for cluster-scoped) key convention frompolicyResultBucket.ts, and merge both report lists before filtering.I have this implemented and tested locally, opening a PR now.