{"record":{"id":"e2f8b37edd90ff07","repo":"AlistGo/alist","slug":"empty-token","errorCode":null,"errorMessage":"empty token","messagePattern":"empty token","errorType":"exception","errorClass":"EmptyToken","httpStatus":null,"severity":"error","filePath":"internal/errs/driver.go","lineNumber":6,"sourceCode":"package errs\n\nimport \"errors\"\n\nvar (\n\tEmptyToken = errors.New(\"empty token\")\n\tLinkIsDir  = errors.New(\"link is dir\")\n)\n","sourceCodeStart":1,"sourceCodeEnd":9,"githubUrl":"https://github.com/AlistGo/alist/blob/843d9dc8149126976b2625911e45a4d3ffd6f2f5/internal/errs/driver.go#L1-L9","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Complete the auth/login flow for the storage and save the token","Verify the token field name expected by the driver matches what you set (token vs refresh_token vs cookie)","Check the stored configuration actually persisted (re-open the storage edit dialog)","For automation, fail provisioning when the token input is blank instead of saving it"],"exampleFix":"// before\nstorage.Addition.Token = strings.TrimSpace(req.Token) // may be \"\"\n\n// after\ntok := strings.TrimSpace(req.Token)\nif tok == \"\" { return errs.EmptyToken }\nstorage.Addition.Token = tok","handlingStrategy":"validation","validationCode":"if strings.TrimSpace(token) == \"\" { return errs.EmptyToken }","typeGuard":"func isEmptyToken(err error) bool { return errors.Is(err, errs.EmptyToken) }","tryCatchPattern":"err := driver.Init(ctx)\nif errors.Is(err, errs.EmptyToken) {\n    return guideUserToLogin() // never retry; token must be supplied\n}","preventionTips":["Fail provisioning when token input is blank; don't save empty credentials","Trim and validate tokens before persisting","Name config fields to match the driver's expected token field"],"tags":["auth","token","validation","config","go"],"backgroundTag":null,"analyzedSha":"843d9dc8149126976b2625911e45a4d3ffd6f2f5","analyzedAt":"2026-08-15T12:14:11.722Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}