Skip to content

[ED-25748] Fix: Healer includes hard failures from earlier attempts of re-run evidence runs - #68

Draft
Svitlana-Dykun wants to merge 2 commits into
mainfrom
ED-25748-healer-include-earlier-attempt-failures
Draft

Svitlana-Dykun wants to merge 2 commits into
mainfrom
ED-25748-healer-include-earlier-attempt-failures

Conversation

@Svitlana-Dykun

@Svitlana-Dykun Svitlana-Dykun commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes the test healer missing hard failures from earlier attempts when an evidence run was re-run. When a GitHub Actions workflow run is re-run, the run ID stays the same but the attempt number increments. Previously, the healer only considered the latest attempt, missing tests that failed in earlier attempts.

Problem

The Playwright test healer in auto mode was only considering the latest attempt of the evidence workflow run. When the evidence run was re-run:

  • A test that failed hard in an earlier attempt but not in the latest one was missed
  • Artifacts from earlier attempts were not considered
  • Job logs from earlier attempts were not scanned

This meant healing candidates were being overlooked.

Solution

Created a new run-attempts.js module that:

  • Queries all attempts of a workflow run using the GitHub API
  • Aggregates failures and artifacts across all attempts
  • Downloads artifacts by unique ID instead of name to handle duplicates

Updated the healer scripts to:

  • collect-log-hard-failures.js: Scan job logs from all attempts and track which attempts each test failed in
  • find-test-evidence.js: Query job logs to determine which attempts a test failed in, then prioritize artifacts from those specific attempts
  • restore-nightly-playwright-builds.js: Handle duplicate artifact names by downloading by ID instead of name

How Attempt/Artifact Selection Works

Evidence Selection (Key Refinement)

When searching for evidence for a specific test:

  1. Query job logs to find which attempt(s) the test actually failed in
  2. Prioritize artifacts from those failed attempts first
  3. Fall back to other attempts only if no evidence found in failed attempts
  4. Record which attempt the evidence came from

This correctly handles scenarios like:

  • Test fails in attempt 1, passes in attempt 2 → uses evidence from attempt 1
  • Test fails in both attempts → uses evidence from the latest failed attempt (attempt 2)
  • Test not found in logs → falls back to checking all attempts

Artifact Download

When multiple attempts exist:

  1. Job logs: All failed jobs from all attempts are scanned with attempt numbers tracked
  2. Artifacts: All artifacts are listed with their attempt numbers via workflow_run.run_attempt
  3. Downloads: Artifacts are downloaded by unique artifact ID rather than name to handle duplicates correctly

The healer prefers:

  1. Evidence with traces over log-only evidence
  2. Evidence from attempts where the test actually failed
  3. Evidence from later attempts when equally valid
  4. Earlier shard indices as a tiebreaker

Why restore-nightly-playwright-builds.js Was Changed

The restore-nightly-playwright-builds.js change is necessary for this fix. When downloading build artifacts by name from a re-run using gh run download -n <artifact-name>, the command fails or gets confused when multiple artifacts with the same name exist across attempts.

By switching to downloadArtifactById(), we:

  • Handle duplicate artifact names correctly
  • Always get the specific artifact we want (latest attempt for builds)
  • Prevent download failures that would block verification

Without this change, the healer would fail to restore builds from re-run evidence runs, preventing verification even when the fix is correct.

Testing

  • Updated existing tests in find-test-evidence.test.js to include attempt field
  • Added new test: "handles the case where test failed in attempt 1 but not attempt 2"
  • Added new test: "prefers later failed attempt when test failed in multiple attempts"
  • Added collect-log-hard-failures.test.js with tests for parseHardFailureTitles
  • Added basic module structure tests for run-attempts.test.js
  • All 359 tests pass (6 new tests added)

Jira

https://elementor.atlassian.net/browse/ED-25748

Open in Web Open in Cursor 

…idence runs

When a workflow run is re-run, GitHub increments the run_attempt number but keeps
the same run ID. Artifacts and jobs belong to specific attempts, and the healer
was only considering the latest attempt when:
- Collecting hard failures from job logs
- Searching for test evidence artifacts
- Downloading artifacts for verification

This caused the healer to miss tests that failed hard in an earlier attempt but
not in the latest one, or whose artifacts only existed in an earlier attempt.

Changes:
- Add run-attempts.js module to query and aggregate data across all attempts
- Update collect-log-hard-failures.js to collect from all attempts' job logs
- Update find-test-evidence.js to consider artifacts from all attempts,
  preferring trace-backed evidence and later attempts when choosing
- Update restore-nightly-playwright-builds.js to handle duplicate artifact
  names by selecting the latest attempt's version
- Update tests to account for attempt field in evidence candidates
- Log which attempts are being scanned for better observability

The healer now treats any test that failed hard in ANY attempt of the evidence
run as a healing candidate, and correctly downloads artifacts by their unique ID
rather than by name to avoid ambiguity with re-runs.

Ref: ED-25748
Co-authored-by: Svitlana-Dykun <Svitlana-Dykun@users.noreply.github.com>
@wiz-9a149474ff

wiz-9a149474ff Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Wiz Scan Summary

Scanner Findings
Vulnerability Finding Vulnerabilities -
Data Finding Sensitive Data -
Secret Finding Secrets -
IaC Misconfiguration IaC Misconfigurations -
SAST Finding SAST Findings 1 Low
Software Management Finding Software Management Findings -
Total 1 Low

View scan details in Wiz

To detect these findings earlier in the dev lifecycle, try the Wiz Code extension for VS Code, JetBrains, or Visual Studio.

Improves evidence selection to be attempt-aware: when searching for evidence
for a specific test, we now query job logs to determine which attempt(s) the
test actually failed in, and prioritize artifacts from those attempts.

This handles the scenario where a test fails in attempt 1 but passes in
attempt 2 (or doesn't run). Previously, we would prefer attempt 2's artifacts
(latest attempt), which wouldn't contain evidence for the failure. Now we
correctly use evidence from the attempt where the test actually failed.

Changes:
- Add collectHardFailuresWithAttempts() to track which attempts each test
  failed in (returns Map<testName, attempt[]>)
- Update findEvidenceInRun() to query job logs and prefer artifacts from
  attempts where the test failed
- When test failed in multiple attempts, use the latest failed attempt
- Fall back to other attempts only if the failed attempt has no artifacts
- Add parseHardFailureTitles export for testing
- Add tests for 'failed in attempt 1, passed in attempt 2' scenario
- Add tests for parseHardFailureTitles function

Test results: All 359 tests pass (6 new tests added)

The restore-nightly-playwright-builds.js change is kept because it's needed
to handle duplicate build artifact names when downloading from re-runs.
Using downloadArtifactById() instead of 'gh run download -n <name>' prevents
failures when the same artifact name exists in multiple attempts.

Ref: ED-25748
Co-authored-by: Svitlana-Dykun <Svitlana-Dykun@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants