Skip to content

Fix: kube.#List reads the resource its schema declares - #266

Merged
anoop2811 merged 2 commits into
kubevela:mainfrom
briankane:fix/kube-list-params
Oct 14, 2026
Merged

anoop2811 merged 2 commits into
kubevela:mainfrom
briankane:fix/kube-list-params

Conversation

@briankane

@briankane briankane commented Oct 9, 2026 •

Copy link
Copy Markdown
Collaborator

Description of your changes

kube.#List declares $params.resource, but the provider decoded its parameters into
ResourceVars, where the resource is read from value. A call written to the schema reached
List with a nil resource and panicked on GetKind, and so did a call that left out the
optional filter.

List now decodes its own ListVars, reading resource, returns an error when it is missing,
and treats a missing filter as no filter. #263 fixed the same bug in the legacy vela/op
provider; this is the vela/kube one, which it left as it was.

Fixes #

I have:

  • Read and followed KubeVela's contribution process.
  • Related Docs updated properly. Not needed: the documented schema was already right; the provider now follows it.
  • Run make reviewable to ensure this PR is ready for review. Ran gofmt, golangci-lint v2.14.0 and staticcheck v0.8.1 on the changed packages; not the full target.
  • Added backport release-x.y labels to auto-backport this PR if necessary.

How has this code been tested

New pkg/providers/kube/list_cue_test.go calls #List through its CUE, the way a template
does, with and without a filter. The existing tests called
List with Go structs directly, so they never went through the schema. They are updated to
the new parameter type.

Special notes for your reviewer

Unlike #263's legacy fix, there is no fallback to value here: vela/kube's #List schema is
closed under $params, so no caller can have passed the resource there.


Summary by cubic

Fixes kube.#List so it decodes its own ListVars and reads resource from $params.resource, matching its schema. Previously calls written to the schema reached List with a nil resource and panicked, and so did calls that omitted the optional filter. List now returns an error when resource is missing or has an empty apiVersion or kind, and treats an absent filter as no filter.

  • Adds CUE-level tests that call #List the way a template does, with and without a filter, and for an empty apiVersion.

Written for commit 720225a. Summary will update on new commits.

View guided diff

#List declares $params.resource, but List decoded into ResourceVars,
whose resource is tagged "value". A call written to the schema reached
List with a nil resource and panicked on GetKind; so did one that left
out the optional filter. List now decodes its own ListVars, reading
resource, errors when it is missing, and treats an absent filter as
none. kubevela#263 fixed the same bug in the legacy vela/op provider; this is
the vela/kube one.

The existing tests called List with Go structs directly, past the
schema; the new ones call #List through its CUE, as a template does.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XN3yiHyAFaPJXDTk1SK3ko
Signed-off-by: Brian Kane <briankane1@gmail.com>

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

All reported issues were addressed across 3 files

Reply with feedback, questions, or to request a fix.

View guided diff | Re-trigger cubic

Comment thread pkg/providers/kube/kube.go Outdated
Comment thread pkg/providers/kube/list_cue_test.go Outdated
@codecov

codecov Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.42%. Comparing base (d7db9c4) to head (720225a).
⚠️ Report is 30 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main     #266       +/-   ##
===========================================
+ Coverage   62.49%   75.42%   +12.92%     
===========================================
  Files          62       73       +11     
  Lines        4415     5163      +748     
===========================================
+ Hits         2759     3894     +1135     
+ Misses       1324     1269       -55     
+ Partials      332        0      -332     
Flag Coverage Δ
e2etests 30.60% <20.00%> (?)
unit-test 68.21% <100.00%> (+5.72%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

The schema only asks for strings, so an empty apiVersion reached List
and failed later as a client error. List now returns its own error for
an empty apiVersion or kind. The unfiltered test also checks that the
fixture ConfigMaps come back, not just that a list exists.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XN3yiHyAFaPJXDTk1SK3ko
Signed-off-by: Brian Kane <briankane1@gmail.com>

@jerrinfrancis jerrinfrancis left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

lgtm

@jerrinfrancis jerrinfrancis left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

lgtm

@anoop2811
anoop2811 merged commit 3c2e715 into kubevela:main Oct 14, 2026
20 checks passed
@github-actions

Copy link
Copy Markdown

Backport failed for release-0.6, because it was unable to cherry-pick the commit(s).

Please cherry-pick the changes locally and resolve any conflicts.

git fetch origin release-0.6
git worktree add -d .worktree/backport-266-to-release-0.6 origin/release-0.6
cd .worktree/backport-266-to-release-0.6
git switch --create backport-266-to-release-0.6
git cherry-pick -x 3c2e7156426540fa8b006403c403c27d33dd8da7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants