AlistGo/alist · error

get download url failed: {string(res)}

Error message

get download url failed: {string(res)}

What it means

Returned by aliyundrive_open's link() when the get_download_url (v2/file/get_download_url) response contains an empty url field. There is one carve-out: .livp files (Apple Live Photos) fall back to streamsUrl in the configured LIVPDownloadFormat; every other extension with an empty url produces this error, appending the raw response body.

Source

Thrown at drivers/aliyundrive_open/driver.go:118

	return objs, err
}

func (d *AliyundriveOpen) link(ctx context.Context, file model.Obj) (*model.Link, error) {
	res, err := d.request(ctx, limiterLink, "/adrive/v1.0/openFile/getDownloadUrl", http.MethodPost, func(req *resty.Request) {
		req.SetBody(base.Json{
			"drive_id":   d.DriveId,
			"file_id":    file.GetID(),
			"expire_sec": 14400,
		})
	})
	if err != nil {
		return nil, err
	}
	url := utils.Json.Get(res, "url").ToString()
	if url == "" {
		if utils.Ext(file.GetName()) != "livp" {
			return nil, errors.New("get download url failed: " + string(res))
		}
		url = utils.Json.Get(res, "streamsUrl", d.LIVPDownloadFormat).ToString()
	}
	exp := time.Minute
	return &model.Link{
		URL:        url,
		Expiration: &exp,
	}, nil
}

func (d *AliyundriveOpen) Link(ctx context.Context, file model.Obj, args model.LinkArgs) (*model.Link, error) {
	return d.link(ctx, file)
}

func (d *AliyundriveOpen) MakeDir(ctx context.Context, parentDir model.Obj, dirName string) (model.Obj, error) {
	nowTime, _ := getNowTime()
	newDir := File{CreatedAt: nowTime, UpdatedAt: nowTime}
	_, err := d.request(ctx, limiterOther, "/adrive/v1.0/openFile/create", http.MethodPost, func(req *resty.Request) {

View on GitHub (pinned to 843d9dc814)

Solutions

  1. Read the appended response body — it typically contains the exact server reason (NotFound, PermissionDenied, TooManyRequests) and dictates the fix
  2. Refresh the directory listing and retry on the current file_id — stale IDs from cached listings are the most common cause
  3. Verify DriveId matches the drive that actually owns the file (check the file's drive_id in the listing)
  4. Check the Open Platform app's scopes and the token's permissions; re-authorize if the grant is partial
  5. Throttle Link calls (cache the URL for its expire_sec) to avoid per-file rate limits

Example fix

// before
url := utils.Json.Get(res, "url").ToString()
if url == "" {
    if utils.Ext(file.GetName()) != "livp" {
        return nil, errors.New("get download url failed: " + string(res))
    }
    url = utils.Json.Get(res, "streamsUrl", d.LIVPDownloadFormat).ToString()
}

// after — also consult streamsUrl for other media types
url := utils.Json.Get(res, "url").ToString()
if url == "" {
    url = utils.Json.Get(res, "streamsUrl", d.LIVPDownloadFormat).ToString()
}
if url == "" {
    return nil, fmt.Errorf("get download url failed for %s: %s", file.GetID(), string(res))
}
Defensive patterns

Strategy: try-catch

Validate before calling

null

Type guard

// Go
func isDownloadUrlFail(err error) bool {
    return err != nil && strings.HasPrefix(err.Error(), "get download url failed")
}

Try / catch

link, err := d.Link(ctx, file, args)
if isDownloadUrlFail(err) {
    // the appended body states the reason:
    // NotFound -> refresh listing; TooManyRequests -> backoff+retry; permission -> re-auth
    return nil, err
}

Prevention

When it happens

Trigger: Calling Link() on a file whose download URL the Open API refuses to issue: file deleted/moved server-side, drive_id/file_id mismatch, token lacking file scope, rate-limited URL issuance, or a non-livp file type the endpoint returns streamsUrl-only for.

Common situations: Cached listings referencing deleted files; wrong DriveId configured (personal vs. backup drive); self-built (自建) app tokens missing permissions; frequent link requests triggering throttling. The error includes the full JSON body, which usually reveals the server's reason code.

Related errors


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