sortFunc never returns 0, so sorting reorders items with equal values
メンテナーはふだん 2 日以内に返信
@iamrishu11 がすでに取り組んでいます。
2026年9月24日 から。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 78/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- typescript
調査の方向性
web/src/utils/common.ts で sortFunc と sortDateFunc を読むことから始め、次に application forms と encrypt-secret-drawer での使用箇所を確認します。昇順および降順のソートで値が等しい場合(タイムスタンプが等しい場合を含む)を対象としたテストを追加し、既存の並び順を維持しながら既存のソートも引き続き機能することを確認します。
索引モデルが issue の本文から書いたものです。
説明
What happened:
sortFunc in web/src/utils/common.ts never returns 0. When the two values
are equal, a > b is false, so it falls through to the -1 branch:
export const sortFunc = (
a: string | number,
b: string | number,
direction: "ASC" | "DESC" = "ASC"
): number => {
if (direction === "ASC") return a > b ? 1 : -1; // equal -> -1
return a > b ? -1 : 1; // equal -> 1
};
So for identical inputs the comparator reports both a < b and b < a.
Array.prototype.sort is only stable when the comparator returns 0 for equal
elements, so equal elements get shuffled instead of keeping their original
order.
What you expected to happen:
Equal values compare as equal (return 0) and keep their relative order.
How to reproduce it:
Sorting a list where several entries share a name:
const items = [
{ name: "api", id: 1 }, { name: "api", id: 2 }, { name: "api", id: 3 },
{ name: "api", id: 4 }, { name: "api", id: 5 }, { name: "api", id: 6 },
{ name: "web", id: 7 }, { name: "api", id: 8 }, { name: "api", id: 9 },
{ name: "api", id: 10 }, { name: "api", id: 11 }, { name: "api", id: 12 },
];
items.sort((a, b) => sortFunc(a.name, b.name)).map(i => i.id);
actual: 12,11,10,9,8,6,5,4,3,2,1,7
expected: 1,2,3,4,5,6,8,9,10,11,12,7
The equal-named entries come out fully reversed. The exact result also depends
on list length, since V8 switches sorting strategy for larger arrays, so short
lists can look fine while longer ones don't.
Where it shows up:
sortFunc sorts the piped/application lists in the four application forms
(application-form-v0, application-form-v1, application-form-manual-v0,
application-form-manual-v1) and in encrypt-secret-drawer, where duplicate
names are normal. sortDateFunc calls sortFunc, so it has the same problem
for equal timestamps.
web/src/utils/common.ts currently has no test file, which is probably why
this went unnoticed.
- 主要言語
- Go
- スター
- 1.4k
- フォーク
- 391
- 平均マージ
- 4日 1時間
- マージ済み PR(30日)
- 58
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
pipe-cd/pipecd のほかの issue
-
Applications at the repository root are not triggered by new commits対応中かも @Daksha1611 が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
メンテナーはふだん 2 日以内に返信
-
pipedv1 kubernetes plugins ignore trafficRouting.istio.host in K8S_TRAFFIC_ROUTING対応中かも @Dhirenderchoudhary が 1 日前に担当しました。 オープン
難易度 2/5 半日 初心者へのやさしさ 74/100
pipe-cd/pipecd#7626 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 2 日以内に返信
-
pipectl transfer restore application drops backed-up labels対応中かも @bhavishyajain545 が 2 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
pipe-cd/pipecd#7622 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
メンテナーはふだん 2 日以内に返信
似ている issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
kubernetes-sigs/kubebuilder#6187 ·
メンテナーはふだん 1 日以内に返信
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
メンテナーはふだん 2 日以内に返信
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100