Skip to content

Handle empty input gracefully#756

Merged
liamfallon merged 4 commits into
kptdev:mainfrom
nokia:empty-res-list-bytes
May 22, 2026
Merged

Handle empty input gracefully#756
liamfallon merged 4 commits into
kptdev:mainfrom
nokia:empty-res-list-bytes

Conversation

@mozesl-nokia
Copy link
Copy Markdown
Contributor

Previously, running a ResourceListProcessor with the SDK and giving it a 0 length input resulted in a parsing error since we expected a KubeObject to be parsed from said input. This is now handled in this PR.

Added some extra unit tests for things I ran unto during debugging.

Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>
Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>
Copilot AI review requested due to automatic review settings May 22, 2026 09:43
Copy link
Copy Markdown

Copilot AI left a comment

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 updates the Go KRM Functions SDK to treat zero-length (or whitespace-only) input as an empty ResourceList, avoiding a parsing failure and adding regression tests around empty input/serialization.

Changes:

  • Update ParseResourceList to return an empty ResourceList for empty/whitespace input.
  • Harden empty ResourceList YAML serialization by avoiding nil dereferences around FunctionConfig.
  • Add unit tests for Run([]byte{}), ParseResourceList([]byte{}), and ToYAML() on an empty ResourceList.

Reviewed changes

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

File Description
go/fn/run_test.go Adds a regression test asserting Run succeeds with empty input and returns a minimal ResourceList YAML.
go/fn/resourcelist.go Treats empty input as an empty ResourceList; updates parse error message; avoids nil deref when serializing functionConfig.
go/fn/resourcelist_test.go Adds tests for parsing zero bytes and serializing an empty ResourceList without panicking.
go/fn/object.go Makes KubeObject.IsEmpty() safe to call on a nil receiver / nil internal object.

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

Comment thread go/fn/resourcelist.go
Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>
Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>
@liamfallon liamfallon merged commit aac5750 into kptdev:main May 22, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants