AlistGo/alist · error · EmptyToken

empty token

Error message

empty token

What it means

errs.EmptyToken is a sentinel for calling a driver API that requires an access token (or cookie token) when none was configured or the stored token is an empty string. It fails fast before any network request is made.

Source

Thrown at internal/errs/driver.go:6

package errs

import "errors"

var (
	EmptyToken = errors.New("empty token")
	LinkIsDir  = errors.New("link is dir")
)

View on GitHub (pinned to 843d9dc814)

Solutions

  1. Complete the auth/login flow for the storage and save the token
  2. Verify the token field name expected by the driver matches what you set (token vs refresh_token vs cookie)
  3. Check the stored configuration actually persisted (re-open the storage edit dialog)
  4. For automation, fail provisioning when the token input is blank instead of saving it

Example fix

// before
storage.Addition.Token = strings.TrimSpace(req.Token) // may be ""

// after
tok := strings.TrimSpace(req.Token)
if tok == "" { return errs.EmptyToken }
storage.Addition.Token = tok
Defensive patterns

Strategy: validation

Validate before calling

if strings.TrimSpace(token) == "" { return errs.EmptyToken }

Type guard

func isEmptyToken(err error) bool { return errors.Is(err, errs.EmptyToken) }

Try / catch

err := driver.Init(ctx)
if errors.Is(err, errs.EmptyToken) {
    return guideUserToLogin() // never retry; token must be supplied
}

Prevention

When it happens

Trigger: Driver initialization or an authenticated call where Addition.Token / cookie token field is empty — e.g. storage added without completing OAuth/login, token field cleared by config edit, or a driver whose Init() checks for a non-empty token before use.

Common situations: Storage created but the login flow was never completed; token pasted into the wrong config field; environment/config migration dropped the token value; automated setups provisioning storage from templates with placeholder-empty tokens.

Related errors


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