Skip to content

fix: Use GAF network stack for license downloads#6684

Merged
PeterSchafer merged 1 commit intomainfrom
fix/CLI-1402-use-gaf-networking-for-license-downloads
Apr 2, 2026
Merged

fix: Use GAF network stack for license downloads#6684
PeterSchafer merged 1 commit intomainfrom
fix/CLI-1402-use-gaf-networking-for-license-downloads

Conversation

@danskmt
Copy link
Copy Markdown
Contributor

@danskmt danskmt commented Mar 26, 2026

Pull Request Submission Checklist

  • Follows CONTRIBUTING guidelines
  • Commit messages are release-note ready, emphasizing what was changed, not how.
  • Includes detailed description of changes
  • Contains risk assessment (Low | Medium | High)
  • Highlights breaking API changes (if applicable)
  • Links to automated tests covering new functionality
  • Includes manual testing instructions (if necessary)
  • Updates relevant GitBook documentation (PR link: ___)
  • Includes product update to be announced in the next stable release notes

What does this PR do?

Fixes GitHub 429 rate-limiting failures during third-party license preparation (CLI-1402) by switching manual license downloads from a plain http.Client to the GAF network stack.

  • manualLicenseDownload uses an *http.Client from networking.NewNetworkAccess(), which provides automatic retry with backoff on 429/5xx, Retry-After support, and proxy/TLS behaviour aligned with the rest of the CLI.
  • The User-Agent header is set via GAF's AddHeaderField instead of per-request construction.
  • maxDownloadAttempts is set to 5.
  • The client sets an explicit Timeout of 60 seconds so individual downloads cannot hang indefinitely.

Where should the reviewer start?

  • cliv2/scripts/prepare_licenses.gonewHTTPClient (GAF + timeout), updated manualLicenseDownload signature
  • cliv2/scripts/prepare_licenses_test.goTestNewHTTPClient_SetsUserAgent, TestNewHTTPClient_RetriesOn429, and existing tests migrated to testify where touched

How should this be manually tested?

  1. make clean && make build — licenses download successfully using the GAF client
  2. From cliv2/, run go test ./scripts/ (or rely on CI: make openboxtest runs go test -cover ./..., which includes the scripts package)

Any background context you want to provide?

The license step fetches a few files from raw.githubusercontent.com. Parallel CI can trigger 429 responses. The previous client had a fixed timeout but no retries on those responses, so builds could flake. GAF’s middleware adds retries; the 60s client timeout caps how long a single download can block.

What's the product update that needs to be communicated to CLI users?

None. This is an internal build infrastructure fix with no user-facing changes.

Risk assessment (Low | Medium | High)?

Low — only affects build-time license preparation, not CLI runtime behaviour. GAF is already a dependency and its networking stack is used by the CLI itself.

Any background context you want to provide?

The license preparation step downloads a handful of licenses from raw.githubusercontent.com. Under load (e.g. parallel CI jobs), GitHub returns 429 responses. The previous bare http.Client had no retry logic, causing flaky build failures. GAF's networking middleware handles this transparently.

What are the relevant tickets?

CLI-1402

@danskmt danskmt requested review from a team as code owners March 26, 2026 15:02
@snyk-io
Copy link
Copy Markdown

snyk-io Bot commented Mar 26, 2026

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues
Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@snyk-pr-review-bot

This comment has been minimized.

@danskmt danskmt force-pushed the fix/CLI-1402-use-gaf-networking-for-license-downloads branch from 3f38c75 to dccb5a6 Compare March 27, 2026 10:12
@snyk-pr-review-bot

This comment has been minimized.

@danskmt danskmt force-pushed the fix/CLI-1402-use-gaf-networking-for-license-downloads branch from dccb5a6 to bd9bfa8 Compare March 27, 2026 13:40
@snyk-pr-review-bot

This comment has been minimized.

@danskmt danskmt force-pushed the fix/CLI-1402-use-gaf-networking-for-license-downloads branch from bd9bfa8 to 48d6239 Compare March 30, 2026 14:36
@snyk-pr-review-bot

This comment has been minimized.

@danskmt danskmt force-pushed the fix/CLI-1402-use-gaf-networking-for-license-downloads branch from 48d6239 to 1a51921 Compare March 30, 2026 15:59
@snyk-pr-review-bot

This comment has been minimized.

@danskmt danskmt force-pushed the fix/CLI-1402-use-gaf-networking-for-license-downloads branch from 1a51921 to 3f87fc6 Compare March 31, 2026 10:45
@danskmt danskmt changed the title fix: Use GAF network stack for license downloads to fix rate limiting fix: Use GAF network stack for license downloads Mar 31, 2026
@snyk-pr-review-bot

This comment has been minimized.

@danskmt danskmt force-pushed the fix/CLI-1402-use-gaf-networking-for-license-downloads branch from 3f87fc6 to 02ec632 Compare March 31, 2026 10:58
@snyk-pr-review-bot

This comment has been minimized.

@PeterSchafer
Copy link
Copy Markdown
Contributor

@danskmt please cleanup the PR description to the latest state

Comment thread cliv2/scripts/prepare_licenses.go Outdated
Comment thread cliv2/scripts/prepare_licenses.go Outdated
Comment thread cliv2/scripts/prepare_licenses_test.go Outdated
Comment thread cliv2/scripts/prepare_licenses_test.go Outdated
Comment thread cliv2/scripts/prepare_licenses_test.go Outdated
Comment thread cliv2/scripts/prepare_licenses_test.go Outdated
@danskmt danskmt force-pushed the fix/CLI-1402-use-gaf-networking-for-license-downloads branch from 02ec632 to f75c0a0 Compare April 1, 2026 09:10
@snyk-pr-review-bot

This comment has been minimized.

@danskmt danskmt force-pushed the fix/CLI-1402-use-gaf-networking-for-license-downloads branch from f75c0a0 to fe53d19 Compare April 1, 2026 09:29
@snyk-pr-review-bot

This comment has been minimized.

@danskmt danskmt force-pushed the fix/CLI-1402-use-gaf-networking-for-license-downloads branch from fe53d19 to bdf0b5e Compare April 1, 2026 09:52
@snyk-pr-review-bot

This comment has been minimized.

@PeterSchafer PeterSchafer enabled auto-merge April 1, 2026 16:47
@PeterSchafer PeterSchafer force-pushed the fix/CLI-1402-use-gaf-networking-for-license-downloads branch from bdf0b5e to b1824a2 Compare April 1, 2026 16:48
@snyk-pr-review-bot

This comment has been minimized.

@PeterSchafer PeterSchafer force-pushed the fix/CLI-1402-use-gaf-networking-for-license-downloads branch from b1824a2 to 835194f Compare April 1, 2026 20:21
@snyk-pr-review-bot
Copy link
Copy Markdown

PR Reviewer Guide 🔍

🧪 PR contains tests
🔒 No security concerns identified
⚡ No major issues detected
📚 Repository Context Analyzed

This review considered 8 relevant code sections from 8 files (average relevance: 1.00)

@PeterSchafer PeterSchafer merged commit 3e97fc1 into main Apr 2, 2026
9 checks passed
@PeterSchafer PeterSchafer deleted the fix/CLI-1402-use-gaf-networking-for-license-downloads branch April 2, 2026 08:22
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