Skip to content

NO-ISSUE: Sort gate check-runs by started_at, not nonexistent created_at - #936

Merged
eliorerz merged 1 commit into
osac-project:mainfrom
eliorerz:fix/gate-latest-sort-field
Sep 13, 2026
Merged

eliorerz merged 1 commit into
osac-project:mainfrom
eliorerz:fix/gate-latest-sort-field

Conversation

@eliorerz

@eliorerz eliorerz commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

Urgent -- caused an incorrect result on PR #927

Found live: `native_gate_conclusion` picked a real failure over a later real success for `e2e-caas-gate`, refusing to correct an already-mis-cancelled orphan that should have been fixed.

Root cause: check-run objects have no `created_at` field at all -- verified directly against the raw API response, only `started_at`/`completed_at` exist. `sort_by(.created_at) | last` was therefore sorting on a field that's always `null` for every entry, so "last" just picked whichever check-run happened to land last in the API's response order, not the chronologically latest attempt. In #927's case, an older failure run landed after a newer success run in the response, and the script trusted the failure.

Fix

Switched to `sort_by(.started_at)`, which every check-run has regardless of whether it has completed yet (unlike `completed_at`, which is null for anything still `in_progress` and would have the exact same problem in reverse).

Test plan

Also worth knowing

The identical `sort_by(.created_at)` pattern exists in `osac-test-infra`'s `e2e-gates-lib.sh` (used by the #542 auto-heal follow-up jobs and my #934 `workflow_run` handler) -- same bug, different repo. Opening a companion fix there.

CI

  • native_gate_conclusion now sorts native gate check-runs by started_at.
  • This selects the latest attempt by start time.
  • The previous created_at field is not available on check-run objects.
  • Tests cover selecting a later successful run over an earlier failure.
  • Post-merge verification remains pending.

API surface

  • No public or exported entities changed.

Backward compatibility

  • No backward-incompatible change is expected.
  • The fix changes only which existing check-run result the script selects.

Risk classification

  • risk:ship applies because the change is limited to CI result ordering and changes one line.
  • It does not meet risk:show criteria because it does not affect user-visible product behavior.
  • It does not meet risk:ask criteria because it does not affect security, persistence, deployment, or public APIs.
  • No repository-specific risk-labeling guidance was found.

Found live on PR osac-project#927: native_gate_conclusion picked a real failure
over a later real success for e2e-caas-gate, refusing to correct an
already-mis-cancelled orphan that should have been fixed.

Root cause: check-run objects have no created_at field at all (verified
directly against the raw API response -- only started_at/completed_at
exist). sort_by(.created_at) | last was therefore sorting on a field
that's always null for every entry, so "last" just picked whichever
check-run happened to come last in the API's response order, not the
chronologically latest attempt. In osac-project#927's case, that meant an older
failure run landed after a newer success run in the response, and the
script trusted the failure.

Switched to sort_by(.started_at), which every check-run has regardless
of whether it has completed yet (unlike completed_at, which is null
for anything still in_progress and would have the same problem in
reverse). Verified against a mock of osac-project#927's exact two check-runs
(success at 01:21:49, failure at 20:45:51) before pushing: now
correctly identifies success as the latest attempt.
@openshift-ci-robot

Copy link
Copy Markdown

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

Details

In response to this:

Urgent -- caused an incorrect result on PR #927

Found live: `native_gate_conclusion` picked a real failure over a later real success for `e2e-caas-gate`, refusing to correct an already-mis-cancelled orphan that should have been fixed.

Root cause: check-run objects have no `created_at` field at all -- verified directly against the raw API response, only `started_at`/`completed_at` exist. `sort_by(.created_at) | last` was therefore sorting on a field that's always `null` for every entry, so "last" just picked whichever check-run happened to land last in the API's response order, not the chronologically latest attempt. In #927's case, an older failure run landed after a newer success run in the response, and the script trusted the failure.

Fix

Switched to `sort_by(.started_at)`, which every check-run has regardless of whether it has completed yet (unlike `completed_at`, which is null for anything still `in_progress` and would have the exact same problem in reverse).

Test plan

Also worth knowing

The identical `sort_by(.created_at)` pattern exists in `osac-test-infra`'s `e2e-gates-lib.sh` (used by the #542 auto-heal follow-up jobs and my #934 `workflow_run` handler) -- same bug, different repo. Opening a companion fix there.

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 requested review from jhernand and trewest September 13, 2026 04:06
@openshift-ci

openshift-ci Bot commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: eliorerz

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

@coderabbitai

coderabbitai Bot commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: osac-project/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 245a09c7-410c-41e2-8106-9b20c841ed15

📥 Commits

Reviewing files that changed from the base of the PR and between 0fdf68b and e7025e1.

📒 Files selected for processing (1)
  • .github/scripts/complete-stale-e2e-gate-checks.sh

Included review availability: Your plan provides up to 12 included reviews per hour; 10 remain after this review.


Walkthrough

The stale E2E gate check now selects the latest matching native gate run by started_at instead of created_at.

Changes

Native gate ordering

Layer / File(s) Summary
Latest native gate selection
.github/scripts/complete-stale-e2e-gate-checks.sh
native_gate_conclusion now orders matching native gate runs by started_at.

Priority: ⬇️ Low

Estimated code review effort: 1 (Trivial) | ~5 minutes

Change: Bug fix

Suggested labels: risk:ask

Suggested reviewers: minmzzhang

Merge Risk: ⚪ Minimal · up to e7025

The native gate ordering fix is supported by the supplied validation and introduces no identified merge-blocking risk.

🚥 Pre-merge checks | ✅ 11
✅ Passed checks (11 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: sorting gate check-runs by available started_at instead of created_at.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
No-Hardcoded-Secrets ✅ Passed The pull request changes only .github/scripts/complete-stale-e2e-gate-checks.sh, replacing .created_at with .started_at in a jq sort. The changed line contains no credential, token, password, ke…
No-Weak-Crypto ✅ Passed The pull request changes only .github/scripts/complete-stale-e2e-gate-checks.sh, replacing sort_by(.created_at) with sort_by(.started_at). The added line contains no MD5, SHA1, DES, 3DES, RC4, B…
No-Injection-Vectors ✅ Passed PASS. The pull request changes only .created_at to .started_at inside a fixed jq filter in native_gate_conclusion. The filter does not construct SQL, execute shell commands, evaluate data, deser…
Container-Privileges ✅ Passed PASS: The pull request changes only .github/scripts/complete-stale-e2e-gate-checks.sh, replacing .created_at with .started_at in a jq sort. The diff introduces no container or Kubernetes manif…
No-Sensitive-Data-In-Logs ✅ Passed The pull request changes only .created_at to .started_at in a jq sort expression. It adds no logging or output. The script's existing echo statements are unchanged, and the new field is used o…
Ai-Attribution ✅ Passed No AI tool use is mentioned in the authored PR description or reviewed commit. The single commit has no Assisted-by, Generated-by, or AI-related Co-Authored-By trailer. The `AI-generated summary…
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown

E2E on CodeRabbit approval

CodeRabbit APPROVED — starting expensive e2e (PR run replay).

  • Started: 3/3

@github-actions

Copy link
Copy Markdown

🧭 E2E Suite Selection (POC, informational only)

Suite Decision Source Reason
VMAAS skip deterministic No changed files matched a path rule for this suite
CAAS skip deterministic No changed files matched a path rule for this suite
BMAAS skip deterministic No changed files matched a path rule for this suite

No AI validation needed -- nothing in this PR was recognized as relevant to any E2E suite. This comment is informational only; nothing is gated on it yet.

@eliorerz
eliorerz merged commit 38fba47 into osac-project:main Sep 13, 2026
150 of 160 checks passed
@eliorerz
eliorerz deleted the fix/gate-latest-sort-field branch September 13, 2026 04:13
eliorerz added a commit to osac-project/osac-test-infra that referenced this pull request Sep 13, 2026
Companion fix to osac-project/osac#936. Found live on osac PR #927:
a manual cleanup script sharing this exact sort_by(.created_at) | last
pattern picked a real failure over a later real success for
e2e-caas-gate.

Root cause: check-run objects have no created_at field at all (verified
directly against the raw API response -- only started_at/completed_at
exist). sort_by(.created_at) | last therefore sorts on a field that's
always null for every entry, so "last" just picks whichever check-run
happens to land last in the API's response order, not the
chronologically latest attempt.

This same pattern is used by latest_gate_conclusion and
native_gate_job_success, which back both the OSAC-1735 auto-heal
follow-up jobs (osac#542) and the workflow_run-based fork-PR handler
(osac#934) -- both call into this file via the complete-stale-e2e-gates
action. Switched both to sort_by(.started_at), which every check-run
has regardless of whether it has completed yet (unlike completed_at,
which is null for anything still in_progress and would have the same
problem in reverse).

This branch had an error being deployed

1 failed deployment
e2e-test — e7025e1d Deployed Sep 13, 2026 by eliorerz via e2e-caas-full-install / e2e #5464
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants