Skip to content

fix(smartmirror): use GET instead of HEAD for mirror connectivity testing - #480

Open
qiuzhiqian wants to merge 1 commit into
masterfrom
fix-smart-mirror
Open

fix(smartmirror): use GET instead of HEAD for mirror connectivity testing#480
qiuzhiqian wants to merge 1 commit into
masterfrom
fix-smart-mirror

Conversation

@qiuzhiqian

@qiuzhiqian qiuzhiqian commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

PMS: BUG-369443

Summary by Sourcery

Bug Fixes:

  • Use GET requests instead of HEAD requests when testing smart mirror connectivity and validating Release URLs.

@sourcery-ai

sourcery-ai Bot commented Aug 28, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Updates all smart-mirror connectivity tests from HTTP HEAD to GET, covering Release routing, parallel mirror selection, and final URL validation to support mirrors that do not handle HEAD correctly.

Sequence diagram for smart-mirror GET connectivity testing

sequenceDiagram
    participant Client
    participant SmartMirror
    participant Mirror

    Client->>SmartMirror: route(original, officialMirror)
    SmartMirror->>Mirror: GET original Release URL
    Mirror-->>SmartMirror: URL and status
    SmartMirror-->>Client: routed URL

    SmartMirror->>SmartMirror: makeChoice(original, officialMirror)
    par Test mirror candidates
        SmartMirror->>Mirror: GET candidate mirror URL
        Mirror-->>SmartMirror: URL and status
    and Test mirror candidates
        SmartMirror->>Mirror: GET candidate mirror URL
        Mirror-->>SmartMirror: URL and status
    end
    SmartMirror->>Mirror: GET original URL for final validation
    Mirror-->>SmartMirror: validation response
Loading

File-Level Changes

Change Details Files
Switch mirror connectivity probes from HEAD requests to GET requests.
  • Use GET when checking Release file URLs during routing.
  • Use GET for concurrent mirror availability and latency checks.
  • Use GET when validating the original URL after selecting and reporting mirror quality.
src/lastore-smartmirror-daemon/smartmirror.go

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@github-actions

Copy link
Copy Markdown

CLA Assistant Lite bot:
提交邮箱中包含我们的合作伙伴,但您似乎并非合作伙伴的成员或对接人,请联系相关对接人将您添加至组织之中,或由其重新发起 Pull Request。
The commit email domain belongs to one of our partners, but it seems you are not yet a member of the current organization, please contact the contact person to add you to the organization or let them submit the Pull Request.

xml seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You can retrigger this bot by commenting recheck in this Pull Request

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: qiuzhiqian

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="src/lastore-smartmirror-daemon/smartmirror.go" line_range="157-158" />
<code_context>
 		return s.makeChoice(original, officialMirror)
 	} else if strings.Contains(original, "/dists/") && strings.HasSuffix(original, "Release") {
 		// Get Release from Release
-		url, _ := handleRequest(buildRequest(makeHeader(), "HEAD", original))
+		url, _ := handleRequest(buildRequest(makeHeader(), "GET", original))
 		return url
 	} else if strings.Contains(original, "/dists/") && strings.Contains(original, "/by-hash/") {
 		return s.makeChoice(original, officialMirror)
</code_context>
<issue_to_address>
**issue (performance):** The connectivity checks now issue unrestricted GET requests for Release and package URLs. `handleRequest` closes each response body without consuming it, so every probe still starts a real payload transfer and causes unnecessary mirror bandwidth and server load; `makeChoice` additionally performs another GET against the original package URL when reporting results.

**Triggers:** When routing pool files or Release files, especially when the requested artifact is large.

**Suggested fix:** Use a GET request with an appropriate small `Range` header, or otherwise limit the response body while retaining the GET method required by affected mirrors.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines -157 to 158
url, _ := handleRequest(buildRequest(makeHeader(), "HEAD", original))
url, _ := handleRequest(buildRequest(makeHeader(), "GET", original))
return url

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

issue (performance): The connectivity checks now issue unrestricted GET requests for Release and package URLs. handleRequest closes each response body without consuming it, so every probe still starts a real payload transfer and causes unnecessary mirror bandwidth and server load; makeChoice additionally performs another GET against the original package URL when reporting results.

Triggers: When routing pool files or Release files, especially when the requested artifact is large.

Suggested fix: Use a GET request with an appropriate small Range header, or otherwise limit the response body while retaining the GET method required by affected mirrors.

@deepin-bot

deepin-bot Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

TAG Bot

New tag: 6.2.68
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #481

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