Skip to content

fix(autodiscovery/kubernetes): handle empty yaml#8943

Merged
olblak merged 2 commits into
updatecli:mainfrom
olblak:issue/8915
May 20, 2026
Merged

fix(autodiscovery/kubernetes): handle empty yaml#8943
olblak merged 2 commits into
updatecli:mainfrom
olblak:issue/8915

Conversation

@olblak

@olblak olblak commented May 19, 2026

Copy link
Copy Markdown
Member

Fix #8915

In version v0.115.0 we introduced the ability to update multiple YAML document but I didn't handle well test case where an empty yaml was loaded which would result to its data to be set to nil. I fix the problem and added a test case

Test

To test this pull request, you can run the following commands:

cd pkg/plugins/autodiscovery/kubernetes/
go test

Additional Information

Checklist

  • I have updated the documentation via pull request in website repository.

Tradeoff

Potential improvement

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a nil-pointer panic in the Kubernetes autodiscovery crawler introduced when support for multi-document YAML was added, by ensuring empty YAML documents don’t produce nil decoded structs and by safely skipping any nil entries during discovery.

Changes:

  • Skip storing nil decoded documents in getManifestData to avoid propagating empty YAML docs.
  • Add nil guards in Kubernetes and Prow manifest discovery loops.
  • Extend test coverage with empty-YAML fixtures and allow “no manifest” scenarios to pass.

Reviewed changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
pkg/plugins/autodiscovery/kubernetes/utils.go Avoids inserting nil decoded YAML documents into the returned map.
pkg/plugins/autodiscovery/kubernetes/utils_test.go Updates file-search expectations to include new empty YAML fixtures.
pkg/plugins/autodiscovery/kubernetes/testdata/empty/kubernetes.1.yaml Adds an empty YAML fixture file (0 bytes) for regression coverage.
pkg/plugins/autodiscovery/kubernetes/testdata/empty/kubernetes.2.yaml Adds an “empty document” YAML fixture (---) for regression coverage.
pkg/plugins/autodiscovery/kubernetes/prow.go Skips nil document entries during Prow manifest discovery to prevent panics.
pkg/plugins/autodiscovery/kubernetes/main.go Adjusts handling/logging when no working directory is defined.
pkg/plugins/autodiscovery/kubernetes/main_test.go Adds a “no manifest” test case and removes the hard failure on zero pipelines.
pkg/plugins/autodiscovery/kubernetes/kubernetes.go Skips nil document entries during Kubernetes manifest discovery to prevent panics.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/plugins/autodiscovery/kubernetes/main.go
@olblak olblak merged commit 10f297c into updatecli:main May 20, 2026
11 checks passed
@olblak olblak added autodiscovery All things related to the autodiscovery feature plugin-kubernetes labels May 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autodiscovery All things related to the autodiscovery feature bug Something isn't working plugin-kubernetes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Kubernetes Autodiscovery: panic: runtime error: invalid memory address or nil pointer dereference

2 participants