{"record":{"id":"929db352b1f58fc4","repo":"AlistGo/alist","slug":"access-token-is-empty","errorCode":null,"errorMessage":"access token is empty","messagePattern":"access token is empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/guangyapan/driver.go","lineNumber":538,"sourceCode":"\n\tif parentID == \"\" {\n\t\treturn \"\", fmt.Errorf(\"resolve root folder path failed: folder %q not found under /\", name)\n\t}\n\treturn \"\", fmt.Errorf(\"resolve root folder path failed: folder %q not found under parent %s\", name, parentID)\n}\n\nfunc (d *GuangYaPan) ensureAccessToken(ctx context.Context) error {\n\tif strings.TrimSpace(d.AccessToken) != \"\" {\n\t\treturn nil\n\t}\n\tif strings.TrimSpace(d.RefreshToken) == \"\" {\n\t\tif d.canSMSLogin() {\n\t\t\treturn d.loginBySMSCode(ctx)\n\t\t}\n\t\tif d.PhoneNumber != \"\" {\n\t\t\treturn errors.New(\"not logged in yet: please fill verify_code and save storage to finish SMS login\")\n\t\t}\n\t\treturn errors.New(\"access token is empty\")\n\t}\n\treturn d.refreshToken(ctx)\n}\n\nfunc (d *GuangYaPan) validateToken(ctx context.Context) error {\n\tvar me userMeResp\n\tresp, err := d.accountClient.R().\n\t\tSetContext(ctx).\n\t\tSetHeader(\"Authorization\", \"Bearer \"+d.AccessToken).\n\t\tSetResult(&me).\n\t\tGet(\"/v1/user/me\")\n\tif err != nil {\n\t\treturn err\n\t}\n\tif resp.IsError() {\n\t\treturn fmt.Errorf(\"validate token failed: status=%d body=%s\", resp.StatusCode(), resp.String())\n\t}\n\tif strings.TrimSpace(me.Sub) == \"\" {","sourceCodeStart":520,"sourceCodeEnd":556,"githubUrl":"https://github.com/AlistGo/alist/blob/843d9dc8149126976b2625911e45a4d3ffd6f2f5/drivers/guangyapan/driver.go#L520-L556","documentation":"Thrown by GuangYaPan.ensureAccessToken when the driver has neither an access token nor a refresh token in storage, and cannot fall back to SMS login (no phone number on record). It means the storage was never fully authenticated. Every GuangYaPan API path funnels through this check, so nothing works until login state exists.","triggerScenarios":"Calling any GuangYaPan operation (List, offline resolve, upload, etc.) on a freshly added storage where access_token and refresh_token are both blank in the driver storage and the SMS-login preconditions (phone + canSMSLogin) are absent. It is the terminal branch of ensureAccessToken: TrimSpace(AccessToken)==\"\" AND TrimSpace(RefreshToken)==\"\" AND !canSMSLogin() AND PhoneNumber==\"\".","commonSituations":"New GuangYaPan mount left half-configured; tokens wiped by a storage reset or a failed migration; SMS login started but verify_code never supplied in a previous session.","solutions":["Re-open the storage config in the admin UI and complete authentication so access_token (or at least refresh_token) is persisted","If the driver supports SMS login, fill in the phone number field so ensureAccessToken can route to loginBySMSCode instead of failing","If a refresh token exists in another environment, copy the full driver storage JSON (tokens included) into this storage entry","Verify with a read-only List call that the error disappears after tokens are saved"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// before any GuangYaPan call, confirm the storage carries credentials\nif d.AccessToken == \"\" && d.RefreshToken == \"\" && d.PhoneNumber == \"\" {\n\treturn errors.New(\"guangyapan storage is not logged in: configure tokens or phone for SMS login\")\n}","typeGuard":"func isGuangYaPanUnauthenticated(d *GuangYaPan) bool {\n\treturn strings.TrimSpace(d.AccessToken) == \"\" &&\n\t\tstrings.TrimSpace(d.RefreshToken) == \"\" &&\n\t\tstrings.TrimSpace(d.PhoneNumber) == \"\"\n}","tryCatchPattern":null,"preventionTips":["Always complete the login flow when adding the storage; verify with a List call before enabling it","Treat the message 'access token is empty' from ensureAccessToken as a config-completion signal, not a transient error","Automate a post-config smoke test (list root) so half-configured storages are caught at setup time"],"tags":["guangyapan","authentication","config","driver"],"backgroundTag":null,"analyzedSha":"843d9dc8149126976b2625911e45a4d3ffd6f2f5","analyzedAt":"2026-08-15T12:14:11.722Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}