Skip to content

NO-JIRA: skip duplicate Analysis stage in approve & upgrade flow#12

Merged
openshift-merge-bot[bot] merged 1 commit into
openshift:mainfrom
jrangelramos:fix/duplicate-analysis-stage-approval
Jul 15, 2026
Merged

NO-JIRA: skip duplicate Analysis stage in approve & upgrade flow#12
openshift-merge-bot[bot] merged 1 commit into
openshift:mainfrom
jrangelramos:fix/duplicate-analysis-stage-approval

Conversation

@jrangelramos

@jrangelramos jrangelramos commented Jun 17, 2026

Copy link
Copy Markdown
Member

Stacked on #15 — this PR is rebased on top of the Proposal → AgenticRun rename. The diff will show all changes from #15 until it merges; after that, only this PR's single commit will remain.

Summary

  • When an ApprovalPolicy auto-approves the Analysis stage, clicking "Approve & upgrade" failed with Duplicate value: {"type":"Analysis"} because approveStage('Analysis') was called unconditionally
  • Now checks if the Analysis stage already exists in the AgenticRunApproval before calling approveStage, preventing the duplicate key API error

Test plan

  • With an ApprovalPolicy that auto-approves Analysis, click "Approve & upgrade" — should succeed without duplicate error
  • Without an ApprovalPolicy (manual approval), click "Approve & upgrade" — should still call approveStage('Analysis') normally
  • yarn test passes (56/56)

🤖 Generated with Claude Code

@openshift-ci openshift-ci Bot requested review from DavidHurta and fao89 June 17, 2026 17:10
@jhadvig

jhadvig commented Jun 18, 2026

Copy link
Copy Markdown
Member

Thanks for catching this @jrangelramos 🏆 the bug is real and the fix is correct for the DecisionActions path.

However, there's a second unguarded caller of approveStage('Analysis') in UpdatePlanTab.tsx:177 (handleAnalyse) that has the same problem.... if an ApprovalPolicy auto-approves Analysis, the "Analyse" button in the Active Update Plans tab will also hit the duplicate error.

Rather than adding the same guard at every call site, could we move the dedup check into useApprovalActions.approveStage() itself? A one-liner at the top of the function:

const existingStages = currentApproval.spec?.stages ?? [];
if (existingStages.some((s) => s.type === stageType)) return true;  // already approved

This makes approveStage idempotent... calling it when the stage already exists just returns true , which is the right semantic for all callers, current and future.

@jrangelramos jrangelramos force-pushed the fix/duplicate-analysis-stage-approval branch from b48613f to c87396b Compare June 18, 2026 12:39
@jhadvig

jhadvig commented Jun 22, 2026

Copy link
Copy Markdown
Member

LGTM 👍 the idempotent guard in the hook looks great, thanks for moving it there @jrangelramos

One small nit.... approval?.spec?.stages in the handleApproveClick dependency array (DecisionActions.tsx:114) is no longer needed since the guard moved into the hook. It won't break anything, just unnecessary callback re-creation when stages change. Feel free to drop it if you're doing another push, otherwise no big deal.

@jrangelramos jrangelramos force-pushed the fix/duplicate-analysis-stage-approval branch from c87396b to 190d4b9 Compare June 22, 2026 14:46
@jrangelramos

Copy link
Copy Markdown
Member Author

just dropped that! thanks

@jrangelramos

Copy link
Copy Markdown
Member Author

@jhadvig could you PTAL? thanks

@jrangelramos jrangelramos force-pushed the fix/duplicate-analysis-stage-approval branch from 190d4b9 to d62271d Compare July 11, 2026 00:05
@jrangelramos

Copy link
Copy Markdown
Member Author

/hold

@openshift-ci openshift-ci Bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 11, 2026
@jrangelramos

Copy link
Copy Markdown
Member Author

wait for #15 to get merged

Prevents adding a duplicate Analysis stage entry when one already
exists in the AgenticRunApproval spec, avoiding a 409 conflict error.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@jhadvig jhadvig force-pushed the fix/duplicate-analysis-stage-approval branch from d62271d to 5cb010d Compare July 15, 2026 16:44
@jhadvig

jhadvig commented Jul 15, 2026

Copy link
Copy Markdown
Member

/title NO-JIRA: skip duplicate Analysis stage in approve & upgrade flow

@jhadvig jhadvig left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

/lgtm
/approve
/verified by CI

@openshift-ci-robot openshift-ci-robot added the verified Signifies that the PR passed pre-merge verification criteria label Jul 15, 2026
@openshift-ci-robot

Copy link
Copy Markdown

@jhadvig: This PR has been marked as verified by CI.

Details

In response to this:

/lgtm
/approve
/verified by CI

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Jul 15, 2026
@openshift-ci

openshift-ci Bot commented Jul 15, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jhadvig, jrangelramos

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:

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 Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 15, 2026
@openshift-ci

openshift-ci Bot commented Jul 15, 2026

Copy link
Copy Markdown

@jrangelramos: all tests passed!

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@jhadvig

jhadvig commented Jul 15, 2026

Copy link
Copy Markdown
Member

/hold cancel

@openshift-ci openshift-ci Bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 15, 2026
@jhadvig

jhadvig commented Jul 15, 2026

Copy link
Copy Markdown
Member

/retitle NO-JIRA: skip duplicate Analysis stage in approve & upgrade flow

@openshift-ci openshift-ci Bot changed the title fix: skip duplicate Analysis stage in approve & upgrade flow NO-JIRA: skip duplicate Analysis stage in approve & upgrade flow Jul 15, 2026
@openshift-ci-robot

Copy link
Copy Markdown

@jrangelramos: This pull request explicitly references no jira issue.

Details

In response to this:

Stacked on #15 — this PR is rebased on top of the Proposal → AgenticRun rename. The diff will show all changes from #15 until it merges; after that, only this PR's single commit will remain.

Summary

  • When an ApprovalPolicy auto-approves the Analysis stage, clicking "Approve & upgrade" failed with Duplicate value: {"type":"Analysis"} because approveStage('Analysis') was called unconditionally
  • Now checks if the Analysis stage already exists in the AgenticRunApproval before calling approveStage, preventing the duplicate key API error

Test plan

  • With an ApprovalPolicy that auto-approves Analysis, click "Approve & upgrade" — should succeed without duplicate error
  • Without an ApprovalPolicy (manual approval), click "Approve & upgrade" — should still call approveStage('Analysis') normally
  • yarn test passes (56/56)

🤖 Generated with Claude Code

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Jul 15, 2026
@openshift-merge-bot openshift-merge-bot Bot merged commit 34b976d into openshift:main Jul 15, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged. verified Signifies that the PR passed pre-merge verification criteria

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants