Skip to content

ci: improve pr triage script - #12677

Merged
smith-xyz merged 2 commits into
typeorm:masterfrom
smith-xyz:improve-pr-triage-checks
Jul 8, 2026
Merged

smith-xyz merged 2 commits into
typeorm:masterfrom
smith-xyz:improve-pr-triage-checks

Conversation

@smith-xyz

Copy link
Copy Markdown
Collaborator

Description of change

Skips issue link requirement for member, collaborator, owner roles

Marks the task as warning only and not as failure.

Pull-Request Checklist

  • Code is up-to-date with the master branch
  • This pull request links a relevant issue using a closing keyword:
    Fixes #NNNN, Closes #NNNN, or Resolves #NNNN
  • There are new or updated tests validating the change (tests/**.test.ts)
  • Documentation has been updated to reflect this change (docs/docs/**.md)

🛡️ Security fixes: Do not submit security fixes as public PRs — the diff exposes the vulnerability. Use GitHub Security Advisories instead.

@github-actions github-actions Bot added the needs-triage PR needs issue link triage label Jul 8, 2026
@smith-xyz smith-xyz added skip-issue-check Skip issue‑link check for this PR and removed needs-triage PR needs issue link triage labels Jul 8, 2026
@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Jul 8, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (3) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)

Grey Divider


Action required

1. Skip label leaves stale check 🐞 Bug ≡ Correctness
Description
When skip-issue-check is added after an earlier run created a failing check, the new
pull_request_target:labeled run skips the entire job due to the job-level if, so report_check
never executes and the prior failing check remains stale. This makes the label ineffective at
clearing/updating the triage check status and can leave incorrect labels/status on the PR.
Code

.github/workflows/pr-triage.yml[R20-24]

 if: >-
   github.repository == 'typeorm/typeorm' &&
   github.event.pull_request.user.type != 'Bot' &&
-      !contains(github.event.pull_request.labels.*.name, 'skip-issue-check')
+      !contains(github.event.pull_request.labels.*.name, 'skip-issue-check') &&
+      !contains(fromJSON('["MEMBER","COLLABORATOR","OWNER"]'), github.event.pull_request.author_association)
Evidence
The workflow now runs on labeled, but the job cannot run when the label is present, and the only
place that updates the check run is inside the job step; therefore a labeled event adding
skip-issue-check cannot clear/update an existing failing check run.

.github/workflows/pr-triage.yml[7-25]
.github/workflows/pr-triage.yml[61-83]

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

## Issue description
The workflow is triggered on `pull_request_target:labeled`, but the job-level `if` prevents the job from running when `skip-issue-check` is present. As a result, adding the label after a failing run cannot update/clear the existing check run because `report_check` is only called inside the job.
## Issue Context
This workflow uses the Checks API to create/update a check run named `pr-triage / issue-link`. Skipping the job means no API call occurs, leaving prior check runs unchanged.
## Fix Focus Areas
- .github/workflows/pr-triage.yml[7-25]
- .github/workflows/pr-triage.yml[61-83]
### Suggested approach
- Remove `!contains(..., 'skip-issue-check')` from the job-level `if` (so labeled events still execute the job).
- Inside the bash script, detect `skip-issue-check` from `github.event.pull_request.labels.*.name` (pass it via env) and if present:
- call `report_check` with a non-blocking/explicit conclusion (e.g., `neutral`/`skipped`) and an explanatory summary,
- optionally remove/add the relevant triage labels,
- exit early.
- Consider adding the `unlabeled` event type as well, so removing the label re-evaluates the check.

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



Remediation recommended

2. Unvalidated linked-issue success 🐞 Bug ≡ Correctness
Description
The workflow reports a successful issue link and applies the linked-issue label purely from a
regex match, without verifying the referenced issue exists in typeorm/typeorm. This can
incorrectly clear needs-triage and mark the check successful for PRs that reference a non-existent
issue number.
Code

.github/workflows/pr-triage.yml[R96-99]

+          ## Issue linked → success check, swap needs-triage for linked-issue ##
         report_check "success" "Issue linked: #${FIRST_ISSUE}" "PR references issue #${FIRST_ISSUE}."
+          apply_label "$LABEL_LINKED" "$LABEL_TRIAGE"

-          LABEL_COUNT=$(gh issue view "$FIRST_ISSUE" --repo "$REPO" \
-            --json labels --jq '.labels | length' 2>/dev/null || echo "0")
-
-          if [ "$LABEL_COUNT" -gt 0 ]; then
-            apply_label "$LABEL_LINKED" "$LABEL_TRIAGE"
-          else
-            apply_label "$LABEL_TRIAGE" "$LABEL_LINKED"
-          fi
-
-          ## Duplicate check — short (#N) and qualified (typeorm/typeorm#N) forms ##
Evidence
The workflow’s own documentation says linked-issue means a valid issue reference, but the code
path for a found FIRST_ISSUE immediately reports success and applies linked-issue without any
API call (e.g., gh issue view) to confirm the issue exists.

.github/workflows/pr-triage.yml[9-13]
.github/workflows/pr-triage.yml[80-99]

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

## Issue description
The workflow currently treats any syntactically-matching `Fixes/Closes/Resolves #N` reference as valid and immediately reports `success` + applies `linked-issue`. This allows bogus/non-existent issue numbers to pass triage and clears `needs-triage` incorrectly.
## Issue Context
The header comment defines `linked-issue` as meaning the PR body contains a **valid** issue reference, but the current implementation only parses digits and never checks existence via the GitHub API.
## Fix Focus Areas
- .github/workflows/pr-triage.yml[80-99]
## Suggested fix
1. After `FIRST_ISSUE` is extracted, validate the issue exists (and is in `typeorm/typeorm`) before reporting success / swapping labels, e.g.:
 - `gh issue view "$FIRST_ISSUE" --repo "$REPO" --json number --jq '.number'` and check exit code.
2. If validation fails, treat it like “no issue reference found”:
 - report the non-success check conclusion
 - apply `needs-triage` and remove `linked-issue`.
3. Keep duplicate detection only after validation succeeds.

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


3. Action_required not warning-only 🐞 Bug ⚙ Maintainability
Description
The missing-issue path sets the check-run conclusion to action_required, which is still a
non-success terminal conclusion and typically communicates “must be acted on” rather than a warning.
If the intent is a warning-only signal, this conclusion value is semantically mismatched and may be
treated as non-passing by consumers of the check.
Code

.github/workflows/pr-triage.yml[R77-82]

       ## Status check + triage label ##
       if [ -z "$FIRST_ISSUE" ]; then
-            report_check "failure" "$FAIL_TITLE" "$FAIL_SUMMARY"
+            report_check "action_required" "$FAIL_TITLE" "$FAIL_SUMMARY"
         apply_label "$LABEL_TRIAGE" "$LABEL_LINKED"
         exit 0
Evidence
The workflow posts a completed check run with conclusion="$1", and the missing-issue branch now
passes action_required, making the check explicitly non-success.

.github/workflows/pr-triage.yml[61-86]

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

## Issue description
The workflow changed the check run conclusion from `failure` to `action_required` when no issue reference is found. This is still a non-success conclusion and does not clearly implement “warning-only”; it communicates that action is required.
## Issue Context
`report_check()` posts to the Checks API and sets `conclusion` to its first argument.
## Fix Focus Areas
- .github/workflows/pr-triage.yml[61-86]
### Suggested approach
- If you want a warning-only check, change the missing-issue path to use `neutral` (or `skipped`) as the conclusion.
- Update the summary/title to reflect that it is informational (e.g., “Issue link recommended”) if that matches intended policy.

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


Grey Divider

  • Author self-review: I have reviewed the code review findings, and addressed the relevant ones.

Qodo Logo

@smith-xyz
smith-xyz merged commit f5c6aa3 into typeorm:master Jul 8, 2026
14 checks passed
@github-actions github-actions Bot added this to the 1.0 milestone Jul 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-issue-check Skip issue‑link check for this PR

Development

Successfully merging this pull request may close these issues.

2 participants