Skip status and kind filters when all given values are empty - #7099
Open
vipulpandey21 wants to merge 1 commit into
Open
Skip status and kind filters when all given values are empty#7099vipulpandey21 wants to merge 1 commit into
vipulpandey21 wants to merge 1 commit into
Conversation
The loop above skips empty values, so a request like statuses: [""] leaves the slice empty and reading statuses[0] panics. The API server has no recovery interceptor, so this stops the whole control plane. Fixes pipe-cd#7098 Signed-off-by: Vipul Subhash Pandey <vipulpandey7917@gmail.com>
Contributor
|
👋 Hi @vipulpandey21, welcome to PipeCD and thanks for opening your first pull request! We’re really happy to have you here Before your PR gets merged, please check a few important things below. Helpful resources
DCO Sign-offAll commits must include a In case you forget to sign-off your commit(s), follow these steps: For the last commit: git commit --amend --signoff
git push --force-with-leaseFor multiple commits: git rebase --signoff origin/master
git push --force-with-leaseRun checks locallyBefore pushing updates, please run: make checkThis runs the same checks as CI and helps catch issues early. 💬 Need help?If anything is unclear, feel free to ask in this PR or join us on the CNCF Slack in the #pipecd channel. Thanks for contributing to PipeCD! ❤️ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does:
In
APIService.ListDeployments, the status and kind filters are added only when at least one usable value was collected, instead of readingstatuses[0]/kinds[0]on a slice that can be empty.Same guard for
kinds. Behaviour is unchanged when a valid value is given.Why we need it:
The loop right above already skips empty values, so a request like
statuses: [""]leaves the slice empty and the index access panics withindex out of range [0] with length 0. The API server has no recovery interceptor, so the panic stops the whole control plane process, not just that request. It is reachable withpipectl deployment list --status=,. Full details and how I checked it are in #7098.I only added the two guards. I did not change how empty values are treated, since both the handler and pipectl already skip them on purpose.
How I tested it
Added
TestListDeploymentsFilters, which checks which filters actually reach the datastore.Without the fix it reproduces the panic at the old line:
With the fix:
go test ./pkg/app/server/grpcapi/...passes, andgo build ./cmd/pipecd ./cmd/pipectlis fine.go veton that package still prints twocopies lock valuewarnings forRegisterEvent. Those are already on master without my change, so I left them alone.Which issue(s) this PR fixes:
Fixes #7098
Does this PR introduce a user-facing change?: