Skip to content

fix(tests): retry spdx3-validate on transient network flakes - #713

Merged
mlieberman85 merged 1 commit into
mainfrom
fix-spdx3-validate-network-retry
Aug 21, 2026
Merged

fix(tests): retry spdx3-validate on transient network flakes#713
mlieberman85 merged 1 commit into
mainfrom
fix-spdx3-validate-network-retry

Conversation

@mlieberman85

Copy link
Copy Markdown
Contributor

Summary

`spdx3-validate` fetches SPDX schemas from spdx.org on every invocation via `urllib.request.urlopen` + `rdflib.Graph.parse(url)`. When the GHA runner sees a transient TCP reset or DNS blip, the tool fails with `ConnectionResetError: [Errno 104] Connection reset by peer` — even though the SBOM output is fine.

Bit us on PR #710 (m663 US3) and #712 (m663 Polish). Same code + tests, different network weather. This is CI flake source #1 of 3 identified during m663.

Fix

`run_validator` retries up to 3 times with 500ms/1s/2s exponential backoff when the tool's output matches transient network signatures (`ConnectionResetError`, `Connection reset by peer`, `URLError`, `urlopen error`, `TimeoutError`, `temporary failure in name resolution`).

Real SPDX violations don't match any of these strings and short-circuit on the first attempt.

Not addressed here

  • Persistent network outages still fail after 3 attempts (correct — a real outage shouldn't silently pass conformance).
  • Vendoring the schemas would need a fork of upstream `JPEWdev/spdx3-validate`; out of scope.

Follow-on CI flake fixes

Test plan

  • All 15 `spdx3_conformance` tests pass locally
  • Retry logic only triggers on network signatures (real violations bail immediately)
  • `./scripts/pre-pr.sh` green

🤖 Generated with Claude Code

`spdx3-validate` fetches SPDX schemas (spdx-model.ttl,
spdx-json-schema.json, spdx-context.jsonld) from spdx.org on EVERY
invocation via `urllib.request.urlopen` and `rdflib.Graph.parse(url)`.
When the GHA runner sees a transient TCP reset or DNS blip, the tool
fails with `ConnectionResetError: [Errno 104] Connection reset by
peer` — even though the underlying SBOM output is valid.

Bit us on PR #710 (m663 US3) and #712 (m663 Polish): fresh CI runs
that were identical to previous passing runs, failing purely because
the runner's network hiccuped mid-schema-fetch.

## Fix

`run_validator` now retries up to 3 times with exponential backoff
(500ms → 1s → 2s) when the tool's output matches transient network
signatures:

- `ConnectionResetError`
- `Connection reset by peer`
- `URLError`
- `urlopen error`
- `TimeoutError`
- `temporary failure in name resolution`

Real SPDX violations don't match any of these strings and short-
circuit on the first attempt (no retry latency added to genuine
failures).

## Not addressed here

- Persistent network outage in the runner still fails after 3
  attempts — appropriate; a persistent outage isn't flakiness, and
  we shouldn't silently pass conformance without actually validating.
- The underlying "spdx3-validate fetches over the network every run"
  design isn't fixed. The tool is upstream (JPEWdev/spdx3-validate);
  we don't own it. Vendoring the schemas would need a fork.

## Test

Verified locally with the full spdx3_conformance suite (15/15 pass).
No test-behavior change on the happy path. Pre-PR gate green.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@mlieberman85
mlieberman85 merged commit b637860 into main Aug 21, 2026
22 checks passed
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.

1 participant