Skip to content

[main] fix(pipeline-augment): scope PipelineRun match to Pipeline namespace#1178

Open
openshift-cherrypick-robot wants to merge 1 commit into
openshift-pipelines:mainfrom
openshift-cherrypick-robot:cherry-pick-1170-to-main
Open

[main] fix(pipeline-augment): scope PipelineRun match to Pipeline namespace#1178
openshift-cherrypick-robot wants to merge 1 commit into
openshift-pipelines:mainfrom
openshift-cherrypick-robot:cherry-pick-1170-to-main

Conversation

@openshift-cherrypick-robot

Copy link
Copy Markdown
Contributor

This is an automated cherry-pick of #1170

/assign anwesha-palit-redhat

augmentRunsToData() matched PipelineRuns to Pipelines by the
tekton.dev/pipeline label only, ignoring namespace. In the "All
Projects" list view this caused every same-named Pipeline across
namespaces to show the same "Last run", even when the PipelineRun
only existed in one namespace.

Fixes openshift-pipelines#1168

@anwesha-palit-redhat anwesha-palit-redhat 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.

/lgtm

@openshift-ci openshift-ci Bot added the lgtm Looks Good to Me Label label Jul 15, 2026
@openshift-ci

openshift-ci Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: anwesha-palit-redhat, openshift-cherrypick-robot

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:
  • OWNERS [anwesha-palit-redhat]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci Bot added the approved Label for Approved PRs label Jul 15, 2026
@qodo-code-review

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (0) 📜 Skill insights (0)

Grey Divider


Remediation recommended

1. Name-only PLR dedupe 🐞 Bug ≡ Correctness
Description
After this PR, augmentRunsToData only matches PipelineRuns within the same namespace, but the
PipelineRuns list feeding it is deduped by metadata.name only. In all-namespaces (or merged) lists
where two namespaces contain PipelineRuns with the same name, one can be dropped and the
corresponding Pipeline will incorrectly get no latestRun.
Code

src/components/utils/pipeline-augment.ts[R107-110]

    const prsForPipeline = pipelineruns.filter(
      (pr) =>
+        pr.metadata.namespace === pipeline.metadata.namespace &&
        pr.metadata.labels?.['tekton.dev/pipeline'] === pipeline.metadata.name,
Evidence
The PR adds namespace-scoped matching in augmentRunsToData; PipelinesList supplies PipelineRuns from
useGetPipelineRuns; useGetPipelineRuns calls usePipelineRuns which delegates to useRuns; useRuns
dedupes non-TaskRun resources (including PipelineRuns) by metadata.name only, which is not unique
across namespaces and can therefore drop valid runs before matching.

src/components/utils/pipeline-augment.ts[102-114]
src/components/pipelines-list/PipelinesList.tsx[35-49]
src/components/hooks/useTektonResult.ts[117-145]
src/components/hooks/useTaskRuns.ts[206-217]
src/components/hooks/useTaskRuns.ts[396-403]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`augmentRunsToData` now correctly requires `PipelineRun.metadata.namespace` to match `Pipeline.metadata.namespace`, but the PipelineRun list coming from `useRuns` is deduped with `uniqBy(..., r => r.metadata.name)`. Because names are only unique *within* a namespace, this can drop legitimate PipelineRuns from other namespaces; with the new namespace scoping, the affected pipelines will end up with `latestRun = null` even though a run exists.

### Issue Context
Data flow:
- `PipelinesList` passes `pipelineRuns` from `useGetPipelineRuns(namespace)` into `augmentRunsToData`.
- `useGetPipelineRuns` uses `usePipelineRuns`.
- `usePipelineRuns` uses `useRuns`, which dedupes PipelineRuns by `metadata.name` only.

### Fix Focus Areas
- src/components/hooks/useTaskRuns.ts[396-403]
- src/components/pipelines-list/PipelinesList.tsx[38-49]
- src/components/hooks/useTektonResult.ts[117-145]
- src/components/hooks/useTaskRuns.ts[206-217]

### Suggested fix
Change the PipelineRun dedupe key to include namespace (e.g., `${r.metadata.namespace ?? ''}/${r.metadata.name}`) instead of `r.metadata.name` alone, so same-named runs in different namespaces are not collapsed.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Qodo Logo

Comment on lines 107 to 110
const prsForPipeline = pipelineruns.filter(
(pr) =>
pr.metadata.namespace === pipeline.metadata.namespace &&
pr.metadata.labels?.['tekton.dev/pipeline'] === pipeline.metadata.name,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Remediation recommended

1. Name-only plr dedupe 🐞 Bug ≡ Correctness

After this PR, augmentRunsToData only matches PipelineRuns within the same namespace, but the
PipelineRuns list feeding it is deduped by metadata.name only. In all-namespaces (or merged) lists
where two namespaces contain PipelineRuns with the same name, one can be dropped and the
corresponding Pipeline will incorrectly get no latestRun.
Agent Prompt
### Issue description
`augmentRunsToData` now correctly requires `PipelineRun.metadata.namespace` to match `Pipeline.metadata.namespace`, but the PipelineRun list coming from `useRuns` is deduped with `uniqBy(..., r => r.metadata.name)`. Because names are only unique *within* a namespace, this can drop legitimate PipelineRuns from other namespaces; with the new namespace scoping, the affected pipelines will end up with `latestRun = null` even though a run exists.

### Issue Context
Data flow:
- `PipelinesList` passes `pipelineRuns` from `useGetPipelineRuns(namespace)` into `augmentRunsToData`.
- `useGetPipelineRuns` uses `usePipelineRuns`.
- `usePipelineRuns` uses `useRuns`, which dedupes PipelineRuns by `metadata.name` only.

### Fix Focus Areas
- src/components/hooks/useTaskRuns.ts[396-403]
- src/components/pipelines-list/PipelinesList.tsx[38-49]
- src/components/hooks/useTektonResult.ts[117-145]
- src/components/hooks/useTaskRuns.ts[206-217]

### Suggested fix
Change the PipelineRun dedupe key to include namespace (e.g., `${r.metadata.namespace ?? ''}/${r.metadata.name}`) instead of `r.metadata.name` alone, so same-named runs in different namespaces are not collapsed.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

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

Labels

approved Label for Approved PRs Bug fix lgtm Looks Good to Me Label Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants