Skip to content

fix(grpcapi): skip the status and kind filters when all given values are empty - #7497

Open
harshalsp07 wants to merge 2 commits into
pipe-cd:masterfrom
harshalsp07:fix/7098-list-deployments-empty-status
Open

harshalsp07 wants to merge 2 commits into
pipe-cd:masterfrom
harshalsp07:fix/7098-list-deployments-empty-status

Conversation

@harshalsp07

@harshalsp07 harshalsp07 commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

What this PR does:

ListDeployments skipped empty values while collecting the status and kind filters, then read statuses[0] / kinds[0] from the result. A request whose values were all empty, for example pipectl deployment list --status=,, indexed an empty slice and panicked.

The filters are now added only when a non-empty value survived the skip, so an all-empty input behaves the same as no filter at all.

Why we need it:

The API server has no recovery interceptor, so the panic stopped the whole control plane process instead of failing one request. The status and kind fields are free text rather than typed enums, so any client with an API key can reach this with a single bad flag value.

Which issue(s) this PR fixes:

Fixes #7098

Does this PR introduce a user-facing change?:

  • How are users affected by this change: pipectl deployment list --status=, no longer takes the control plane down. The request is treated as "no filter".
  • Is this breaking change: No
  • How to migrate (if breaking change): N/A

How to test:

go test ./pkg/app/server/grpcapi/... covers all-empty, mixed, valid and invalid values for both fields, plus the case where a status and a kind are given together.

Without the fix the new test panics at the old line:

panic: runtime error: index out of range [0] with length 0
    .../pkg/app/server/grpcapi/api.go:553

Note: #7099 is an earlier attempt at the same fix. It is based on an older master and currently conflicts, so this PR supersedes it.

@harshalsp07
harshalsp07 requested a review from a team as a code owner October 19, 2026 07:33
@harshalsp07
harshalsp07 requested review from ffjlabo, khanhtc1202 and t-kikuc and a balanced review from Copilot October 19, 2026 07:33
@netlify

netlify Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for pipecd-site canceled.

Name Link
🔨 Latest commit 07d8933
🔍 Latest deploy log https://app.netlify.com/projects/pipecd-site/deploys/6ae0e5cf46df5ac4e977e407

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.

🟢 Approval recommended

Both panic paths are safely guarded while preserving existing filtering behavior, with no blocking issues identified.

No open issues 🎉

What changed in this PR

Fixes #7098 by preventing control-plane panics when ListDeployments receives only empty status or kind values.

Changes:

  • Adds filters only when non-empty values remain, preserving existing validation.
  • Adds regression tests for empty, valid, invalid, and mixed status inputs.
File Description
pkg/​app/​server/​grpcapi/​api.go Guards status and kind indexing against empty slices.
pkg/​app/​server/​grpcapi/​api_test.go Tests filter construction and invalid-input handling.

Review effort: Balanced

@harshalsp07 harshalsp07 changed the title Fix ListDeployments panic when statuses or kinds contain only empty values fix(grpcapi): skip the status and kind filters when all given values are empty Oct 20, 2026
@codecov

codecov Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 31.04%. Comparing base (4e42b4f) to head (07d8933).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7497      +/-   ##
==========================================
+ Coverage   30.94%   31.04%   +0.10%     
==========================================
  Files         602      602              
  Lines       52856    52856              
==========================================
+ Hits        16357    16410      +53     
+ Misses      34956    34899      -57     
- Partials     1543     1547       +4     
Flag Coverage Δ
. 24.96% <100.00%> (+0.13%) ⬆️
.-pkg-app-pipedv1-plugin-analysis 29.19% <ø> (ø)
.-pkg-app-pipedv1-plugin-ecs 34.97% <ø> (ø)
.-pkg-app-pipedv1-plugin-kubernetes 60.19% <ø> (ø)
.-pkg-app-pipedv1-plugin-kubernetes_multicluster 62.12% <ø> (ø)
.-pkg-app-pipedv1-plugin-scriptrun 58.22% <ø> (ø)
.-pkg-app-pipedv1-plugin-terraform 45.66% <ø> (ø)
.-pkg-app-pipedv1-plugin-wait 32.22% <ø> (ø)
.-pkg-app-pipedv1-plugin-waitapproval 55.14% <ø> (ø)
.-pkg-plugin-sdk 52.07% <ø> (ø)
.-tool-actions-gh-release 20.00% <ø> (ø)
.-tool-actions-plan-preview 27.91% <ø> (ø)
.-tool-codegen-protoc-gen-auth 0.00% <ø> (ø)

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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

…alues

Fixes pipe-cd#7098.

The Status/Kind filters were built by skipping empty strings and then
reading statuses[0]/kinds[0], so a request like --status=, (all values
empty) indexed an empty slice and panicked the control plane process,
which runs without a recovery interceptor.

Build the filters only when a non-empty value survived the skip, and
add regression tests covering all-empty, mixed, valid, and invalid
inputs for both fields.

Signed-off-by: Harshal <[email protected]>
Adds a case where both a status and a kind are given so the test checks that
the two filters are added independently, and makes the error assertion safe
when no error is returned.

Signed-off-by: Harshal <[email protected]>
@harshalsp07
harshalsp07 force-pushed the fix/7098-list-deployments-empty-status branch from 3935324 to 07d8933 Compare October 27, 2026 17:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ListDeployments panics when statuses or kinds contain only empty values

4 participants