fix(tests): retry spdx3-validate on transient network flakes - #713
Merged
Conversation
`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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
Follow-on CI flake fixes
Test plan
🤖 Generated with Claude Code