AlistGo/alist · error

failed to create direct link: %w

Error message

failed to create direct link: %w

What it means

Returned from Gofile Link when createDirectLink fails for a file ID. Gofile requires fetching a server-specific download link (and often a guest/host account token) per file; any failure in that flow is wrapped as 'failed to create direct link: <cause>'.

Source

Thrown at drivers/gofile/driver.go:98

		contents = response.Data.Contents
	}

	for _, content := range contents {
		objects = append(objects, d.convertContentToObj(content))
	}

	return objects, nil
}

func (d *Gofile) Link(ctx context.Context, file model.Obj, args model.LinkArgs) (*model.Link, error) {
	if file.IsDir() {
		return nil, errs.NotFile
	}

	// Create a direct link for the file
	directLink, err := d.createDirectLink(ctx, file.GetID())
	if err != nil {
		return nil, fmt.Errorf("failed to create direct link: %w", err)
	}

	// Configure cache expiration based on user setting
	link := &model.Link{
		URL: directLink,
	}

	// Only set expiration if LinkExpiry > 0 (0 means no caching)
	if d.LinkExpiry > 0 {
		expiration := time.Duration(d.LinkExpiry) * 24 * time.Hour
		link.Expiration = &expiration
	}

	return link, nil
}

func (d *Gofile) MakeDir(ctx context.Context, parentDir model.Obj, dirName string) (model.Obj, error) {
	var parentId string

View on GitHub (pinned to 843d9dc814)

Solutions

  1. Read the wrapped cause: 'gofile API error: ...' identifies the upstream reason (not-found, rate-limit)
  2. Refresh the directory listing to drop deleted files, then retry the download
  3. If rate-limited, back off and reduce parallel downloads from Gofile mounts
  4. Re-init the driver storage so tokens/server info are re-fetched
Defensive patterns

Strategy: try-catch

Try / catch

link, err := d.Link(ctx, file, args)
if err != nil {
  if strings.Contains(err.Error(), "failed to create direct link") {
    // invalidate cached listing for the parent and retry once
  }
}

Prevention

When it happens

Trigger: Opening/downloading a file (Link call) where the Gofile 'contents' download endpoint errors: file deleted, server assignment failing, rate limit, invalid/expired website token, or network failure.

Common situations: File removed upstream but listing cache still shows it; Gofile server rotation invalidating cached links; heavy download traffic hitting Gofile rate limits; expired token used for link creation.

Related errors


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