Skip to content

Conversation

@sinspired
Copy link

@sinspired sinspired commented Dec 20, 2025

I use main fork in my project,I will cancel the old pr and now reopen a new PR。

Summary by CodeRabbit

  • New Features

    • Added support for downloading assets via GitHub Proxy
    • Extended 386 architecture support with additional architecture aliases
  • Tests

    • Enhanced test coverage for 386 architecture variants

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Dec 20, 2025

Walkthrough

The changes extend architecture mapping to support 386 aliases (i386, x86, x86_32), add corresponding test cases for 386 architecture handling, and implement GitHub Proxy asset download detection with direct HTTP GET requests triggered by multiple "https://" occurrences in AssetURL.

Changes

Cohort / File(s) Change Summary
Architecture mapping enhancements
arch.go, arch_test.go
Adds conditional logic to map "386" architecture to additional aliases (i386, x86, x86_32); extends TestAdditionalArch with two new test cases covering 386 with and without universal arch
GitHub Proxy asset download handling
github_source.go
Detects proxy usage by counting "https://" occurrences in AssetURL; when detected, performs direct HTTP GET request instead of standard GitHub API path; selects download URL based on AssetID matching; adds strings import

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • github_source.go: Proxy detection via string occurrence counting and conditional URL selection logic requires careful verification of edge cases and error handling for HTTP non-OK responses
  • arch.go: Verify that new 386 mappings are applied in correct order relative to universalArch handling
  • arch_test.go: Confirm test expectations cover both universal and non-universal cases for 386

Poem

🐰 A rabbit hops through architectures new,
From x86 to 386, we brew,
GitHub proxies found in URLs so long,
Direct downloads whisper their song! 🎵

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the two main changes: adding 386 architecture mappings and GitHub Proxy support for asset downloads.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
github_source.go (2)

104-109: Variable naming: downloadUrl should be downloadURL.

Go convention for acronyms is to use all caps (e.g., URL, HTTP, ID).

🔎 Proposed fix
-		var downloadUrl string
+		var downloadURL string
 		if rel.AssetID == assetID {
-			downloadUrl = rel.AssetURL
+			downloadURL = rel.AssetURL
 		} else if rel.ValidationAssetID == assetID {
-			downloadUrl = rel.ValidationAssetURL
+			downloadURL = rel.ValidationAssetURL
 		}

116-127: Add spacing after colons in error messages for consistency.

Error messages at lines 116, 121, and 127 are missing spaces after the colons.

🔎 Proposed fix
-			return nil, fmt.Errorf("failed to create download request:%w", err)
+			return nil, fmt.Errorf("failed to create download request: %w", err)
-			return nil, fmt.Errorf("download failed:%w", err)
+			return nil, fmt.Errorf("download failed: %w", err)
-			return nil, fmt.Errorf("download failed, status code:%d", resp.StatusCode)
+			return nil, fmt.Errorf("download failed, status code: %d", resp.StatusCode)
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between eb95222 and 496a584.

📒 Files selected for processing (3)
  • arch.go (1 hunks)
  • arch_test.go (1 hunks)
  • github_source.go (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
github_source.go (1)
errors.go (1)
  • ErrAssetNotFound (13-13)
🔇 Additional comments (3)
arch_test.go (1)

26-27: LGTM!

Test cases for the 386 architecture aliases are well-structured and align with the implementation in arch.go. The expected values correctly include all the new aliases in the proper order.

arch.go (1)

30-32: LGTM!

The 386 architecture alias handling follows the established pattern and covers the common naming conventions (i386, x86, x86_32) used in release assets.

github_source.go (1)

114-130: Download logic and error handling are correct.

The request properly uses context, error paths close the response body, and success path correctly leaves the body open for the caller to close.

Comment on lines +97 to +98
// Check if the AssetURL contains more than one "https://"
useGithubProxy := strings.Count(rel.AssetURL, "https://") > 1
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Proxy detection only checks AssetURL, but ValidationAssetURL may differ.

If rel.ValidationAssetURL uses a proxy but rel.AssetURL doesn't (or vice versa), the current logic will use the wrong download path for one of them. Consider checking both URLs or the specific URL being requested.

🔎 Proposed fix
-	// Check if the AssetURL contains more than one "https://"
-	useGithubProxy := strings.Count(rel.AssetURL, "https://") > 1
-	// If the AssetURL contains more than 2 "https://", it means it's using a GitHub Proxy service.
+	// Determine the download URL based on asset ID first
+	var downloadURL string
+	if rel.AssetID == assetID {
+		downloadURL = rel.AssetURL
+	} else if rel.ValidationAssetID == assetID {
+		downloadURL = rel.ValidationAssetURL
+	}
+
+	// Check if the selected URL contains more than one "https://" (indicates GitHub Proxy usage)
+	useGithubProxy := downloadURL != "" && strings.Count(downloadURL, "https://") > 1
+	// If the URL contains more than 1 "https://", it means it's using a GitHub Proxy service.

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In github_source.go around lines 97-98, proxy detection only inspects
rel.AssetURL which can differ from rel.ValidationAssetURL; update the logic to
detect proxies for the actual URL being used (check both rel.AssetURL and
rel.ValidationAssetURL as appropriate) and set useGithubProxy based on the
specific URL you will request (e.g., compute proxy flags for each URL or derive
useGithubProxy = strings.Count(urlBeingRequested, "https://") > 1 so the
download/validation path uses the correct proxy decision).

@sinspired sinspired changed the title Pr Add 386 architecture mappings and GitHub Proxy support Dec 20, 2025
@codecov
Copy link

codecov bot commented Dec 21, 2025

Codecov Report

❌ Patch coverage is 14.28571% with 18 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.95%. Comparing base (d7d55b9) to head (496a584).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
github_source.go 5.26% 17 Missing and 1 partial ⚠️

❌ Your patch check has failed because the patch coverage (14.29%) is below the target coverage (70.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #51      +/-   ##
==========================================
- Coverage   77.07%   76.95%   -0.12%     
==========================================
  Files          28       28              
  Lines        1435     1167     -268     
==========================================
- Hits         1106      898     -208     
+ Misses        279      218      -61     
- Partials       50       51       +1     
Flag Coverage Δ
unittests 76.95% <14.29%> (-0.12%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@creativeprojects
Copy link
Owner

creativeprojects commented Dec 21, 2025

Hi!

Thank you for this pull request! Sorry it took me some time to look at it.

I'm a little bit concerned that the check for the double https:// could break some other users workflow.

Have you tried to check if the Github API is returning the redirected url as a second argument?

On line 139 in the PR, the s.api.Repositories.DownloadReleaseAsset could return nil, redirectedURL, nil
If this is the case, we can download the asset manually once we know the Github API cannot.

From the GitHub documentation:

DownloadReleaseAsset returns an io.ReadCloser that reads the contents of the
specified release asset. It is the caller's responsibility to close the ReadCloser.
If a redirect is returned, the redirect URL will be returned as a string instead
of the io.ReadCloser. Exactly one of rc and redirectURL will be zero.

Sorry I cannot try it myself as I don't know what kind of setup you have.

@sinspired
Copy link
Author

I didn't change your original code, It will be working as normal as it would be. My code will be work Only when the url has two "https" like https://githubporxy.com/https://raw.githubuserconten.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