flipped-aurora/gin-vue-admin · error

下载压缩包失败, HTTP状态码: %d

Error message

下载压缩包失败, HTTP状态码: %d

What it means

The zip file download from the real URL returned a non-200 HTTP status. The code requires 200 before saving the archive to a temp file; any other status (403 expired link, 404 missing file, 5xx storage error) produces this error.

Source

Thrown at server/service/system/sys_skills.go:444

		} `json:"data"`
	}
	if err = json.Unmarshal(metaBody, &meta); err != nil {
		return fmt.Errorf("解析下载结果失败: %w", err)
	}

	realDownloadURL := strings.TrimSpace(meta.Data.URL)
	if realDownloadURL == "" {
		return errors.New("下载结果缺少 url")
	}

	zipResp, err := http.Get(realDownloadURL)
	if err != nil {
		return fmt.Errorf("下载压缩包失败: %w", err)
	}
	defer zipResp.Body.Close()

	if zipResp.StatusCode != http.StatusOK {
		return fmt.Errorf("下载压缩包失败, HTTP状态码: %d", zipResp.StatusCode)
	}

	tmpFile, err := os.CreateTemp("", "gva-skill-*.zip")
	if err != nil {
		return fmt.Errorf("创建临时文件失败: %w", err)
	}
	tmpPath := tmpFile.Name()
	defer os.Remove(tmpPath)

	if _, err = io.Copy(tmpFile, zipResp.Body); err != nil {
		tmpFile.Close()
		return fmt.Errorf("保存技能包失败: %w", err)
	}
	tmpFile.Close()

	if err = extractZipToDir(tmpPath, skillsDir); err != nil {
		return fmt.Errorf("解压技能包失败: %w", err)
	}

View on GitHub (pinned to 3136500ef3)

Solutions

  1. Retry the whole DownloadOnlineSkill flow so a fresh download URL is issued (don't reuse old URLs)
  2. Check the status code and response body of the zip request for auth/expiry hints
  3. Verify the marketplace skill still exists and is downloadable
  4. If 403 persists, check whether the storage host requires referer/token headers that http.Get doesn't send
Defensive patterns

Strategy: retry

Type guard

func isZipDownloadStatusErr(err error) (int, bool) {
    m := regexp.MustCompile(`下载压缩包失败, HTTP状态码: (\d+)`).FindStringSubmatch(err.Error())
    if len(m) < 2 { return 0, false }
    code, _ := strconv.Atoi(m[1])
    return code, true
}

Try / catch

if err := DownloadOnlineSkill(ctx, req); err != nil {
    if code, ok := isZipDownloadStatusErr(err); ok && (code == 403 || code == 404) {
        // download URL expired/invalid: restart the whole flow to get a fresh URL
    }
}

Prevention

When it happens

Trigger: Calling DownloadOnlineSkill when the marketplace-issued download URL has expired (signed URL expiry), the object was deleted, the storage backend rejects the request, or a geo/ACL restriction returns 403.

Common situations: Signed object-storage URLs with short TTL consumed too late; CDN hotlink protection; storage bucket permission changes; marketplace repackaging skills so old URLs 404.

Related errors


AI-assisted analysis of flipped-aurora/gin-vue-admin@3136500ef3 (2026-08-31). Data as JSON: /api/errors/93bb4839225569f6. Report an issue: GitHub.