AlistGo/alist · error

no Location header in redirect response

Error message

no Location header in redirect response

What it means

The SJTU netdisk driver received the expected 301/302 redirect status but the Location header was empty, so it has no S3 presigned URL to hand back. This means the server signaled a redirect without a target — a malformed or proxied response.

Source

Thrown at drivers/sjtu_netdisk/driver.go:171

			"user_id":             d.UserId,
			"content_disposition": "attachment",
			"purpose":             "download",
			"space_org_id":        "1",
		}).
		Execute(http.MethodGet, linkURL)

	if err != nil {
		return nil, err
	}

	// status code is not 301 and 302
	if resp.StatusCode() != http.StatusFound && resp.StatusCode() != http.StatusMovedPermanently {
		return nil, fmt.Errorf("unexpected status code: %d", resp.StatusCode())
	}

	s3URL := resp.Header().Get("Location")
	if s3URL == "" {
		return nil, fmt.Errorf("no Location header in redirect response")
	}

	// parse TTL from S3 presigned URL's X-Amz-Expires parameter
	ttl := 2 * time.Hour
	if u, parseErr := url.Parse(s3URL); parseErr == nil {
		if expiresSec, convErr := strconv.Atoi(u.Query().Get("X-Amz-Expires")); convErr == nil && expiresSec > 0 {
			ttl = time.Duration(expiresSec) * time.Second
		}
	}

	return &model.Link{
		URL:        s3URL,
		Expiration: &ttl,
	}, nil
}

func (d *SJTUNetdisk) MakeDir(ctx context.Context, parentDir model.Obj, dirName string) (model.Obj, error) {
	if err := d.refreshToken(ctx); err != nil {

View on GitHub (pinned to 843d9dc814)

Solutions

  1. Retry the request once — empty Location responses are usually transient server faults
  2. If a proxy sits in front of the endpoint, ensure it passes the Location header through unmodified
  3. Confirm the file is downloadable in the official SJTU client to rule out server-side state
  4. If persistent, capture the raw response (status + headers) and report it as a driver issue
Defensive patterns

Strategy: retry

Try / catch

if err != nil && strings.Contains(err.Error(), "no Location header") {
    // transient or proxy-related; single retry usually resolves it
    return retryLinkOnce()
}

Prevention

When it happens

Trigger: A reverse proxy (nginx/traefik) in front of the API strips or rewrites the Location header; the redirect is relative and dropped by the HTTP client configuration; the server emits 302 with an empty Location due to an internal fault.

Common situations: Self-hosted gateway or corporate proxy between AList and the SJTU API; the API server intermittently failing; client library following redirects automatically and re-sending to an empty target.

Related errors


AI-assisted analysis of AlistGo/alist@843d9dc814 (2026-08-15). Data as JSON: /api/errors/f883576e7757dd19. Report an issue: GitHub.