ListEvents can exceed page size after label filtering

オープン
#7,085 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

まだ誰も着手していません。

  • #7086 @rootp1 による — マージされずにクローズ

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
62/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
静か
技術スタック
go
領域
api, backend

調査の方向性

pkg/app/server/grpcapi/web_api.go の WebAPI.ListEvents とそのラベルでフィルタリングされたページネーションループから開始し、同等の ListDeployments パスと比較します。ラベル結果が密な場合、疎な場合、0 件の場合のテストを追加または更新し、カーソルによる継続でイベントの重複や欠落がなく、レスポンスが PageSize を守ることを確認します。

索引モデルが issue の本文から書いたものです。

説明

What happened:

WebAPI.ListEvents applies label filtering after fetching datastore pages, then keeps appending matching events while scanning additional pages until it has at least PageSize matches. If the final scanned page contains multiple matching events after the threshold is crossed, the response can exceed the requested logical page size. The handler then returns the datastore cursor from the final scanned page, which makes filtered pagination unstable for event timelines.

Summary

ListEvents can return an oversized filtered response when label matches are spread across multiple datastore pages.

Affected Area

pkg/app/server/grpcapi/web_api.go, specifically WebAPI.ListEvents and its label-filtered pagination path.

What you expected to happen:

ListEvents should return one logical filtered page, no larger than the requested PageSize, and provide a cursor suitable for continuing to the next filtered page without duplicates or dropped events.

Expected Behaviour

The API should enforce a stable logical page size after label filtering and return a cursor for the next filtered page.

How to reproduce it:

  1. Seed or mock multiple datastore pages of events with label matches spread across pages.
  2. Call WebAPI.ListEvents with Options.Labels and a PageSize smaller than the total matching events.
  3. Make the first page contain fewer matching events than PageSize, and a later fetched page contain enough matches to cross the threshold by more than one event.
  4. Observe that the response includes more than PageSize events because every matching event from the final scanned page is appended.

Actual Behaviour

The endpoint can return an uncapped list of matched events encountered during the scan, exceeding the requested page size.

Technical Evidence

ListEvents builds datastore ListOptions with Limit: pageSize, fetches one page, filters by labels in memory, then repeats while len(filtered) < pageSize. Inside the repeat loop, every matching event from the newly fetched datastore page is appended. There is currently a TODO noting the overflow risk immediately before returning the response:

  • pkg/app/server/grpcapi/web_api.go: // TODO: Think about possibility that the response of ListEvents exceeds the page size

This mirrors the same post-filter pagination risk that exists in ListDeployments.

Suspected Root Cause

Label filtering happens after datastore pagination, but the filtered slice is never capped back to the requested logical page size before the response is returned. The returned cursor is the datastore cursor from the final scanned page.

Proposed Direction

Refactor the filtered pagination path so ListEvents only returns up to PageSize filtered events. If possible, share the helper with the equivalent ListDeployments path so both handlers use consistent cursor semantics.

Acceptance Criteria

  • ListEvents enforces a stable logical page size after label filtering.
  • Cursor-based continuation yields no duplicate or dropped events.
  • Tests cover dense matches, sparse matches, and zero-match scenarios.

Environment:

  • piped version: Not applicable; this is a control-plane WebAPI handler issue.
  • control-plane version: Current upstream master as of 2026-07-24.
  • Others: Not applicable.
主要言語
Go
スター
1.4k
フォーク
391
平均マージ
4日 1時間
マージ済み PR(30日)
58

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

pipe-cd/pipecd のほかの issue

pipe-cd/pipecd の issue をすべて見る

似ている issue

Go の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。