{"record":{"id":"99a1a361456c7757","repo":"AlistGo/alist","slug":"api-key-is-empty","errorCode":null,"errorMessage":"api_key is empty","messagePattern":"api_key is empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/yunpan360/driver.go","lineNumber":73,"sourceCode":"\t\td.SubChannel = defaultSubChannel\n\t}\n\td.EcsEnv = strings.ToLower(strings.TrimSpace(d.EcsEnv))\n\tif d.EcsEnv == \"\" {\n\t\td.EcsEnv = openEnvProd\n\t}\n\td.Cookie = strings.TrimSpace(d.Cookie)\n\td.APIKey = strings.TrimSpace(d.APIKey)\n\td.OwnerQID = strings.TrimSpace(d.OwnerQID)\n\td.DownloadToken = strings.TrimSpace(d.DownloadToken)\n\td.cachedOpenAuth = nil\n\td.openAuthExpire = time.Time{}\n\td.cachedCookieSession = nil\n\td.cookieSessionExpire = time.Time{}\n\n\tswitch d.authMode() {\n\tcase authTypeAPIKey:\n\t\tif d.APIKey == \"\" {\n\t\t\treturn errors.New(\"api_key is empty\")\n\t\t}\n\t\t_, err := d.openUserInfo(ctx)\n\t\treturn err\n\tcase authTypeCookie:\n\t\tif d.Cookie == \"\" {\n\t\t\treturn errors.New(\"cookie is empty\")\n\t\t}\n\t\t// Web download URLs require browser-session headers; force local proxying\n\t\t// so AList can forward Referer/Origin instead of exposing a bare 302 URL.\n\t\td.WebProxy = true\n\t\t_, err := d.listCookiePage(ctx, d.RootFolderPath, 0, 1)\n\t\treturn err\n\tdefault:\n\t\treturn errors.New(\"invalid auth_type\")\n\t}\n}\n\nfunc (d *Yunpan360) Drop(ctx context.Context) error {","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/AlistGo/alist/blob/843d9dc8149126976b2625911e45a4d3ffd6f2f5/drivers/yunpan360/driver.go#L55-L91","documentation":"Thrown by Yunpan360 Init() when auth_type is set to \"api_key\" but the api_key field is blank after trimming. The driver immediately needs the API key to call openUserInfo (open API auth + validation), so an empty key cannot proceed. Configuration is trimmed first, so a whitespace-only value also triggers this.","triggerScenarios":"Storage config with auth_type=\"api_key\" and an empty/whitespace api_key field; the key was cleared during a config edit or never filled when switching from cookie to api_key mode.","commonSituations":"Switching auth modes in the AList admin UI without filling the new credential; automation/terraform that templates the driver config and omits api_key; trailing spaces that were assumed to be the problem but the field is genuinely empty.","solutions":["Set the api_key field in the yunpan360 storage config to the key obtained from 360's open API","If you meant to use browser-cookie auth, set auth_type back to \"cookie\" and fill cookie instead","Re-save the storage config after editing so Init() runs again"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if cfg.AuthType == \"api_key\" && strings.TrimSpace(cfg.APIKey) == \"\" {\n    return errors.New(\"auth_type=api_key requires a non-empty api_key\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate config completeness before saving the storage","When switching auth modes, clear or fill the matching credential field","Treat whitespace-only keys as empty (the driver trims)"],"tags":["yunpan360","driver","config","auth","api-key","validation"],"backgroundTag":null,"analyzedSha":"843d9dc8149126976b2625911e45a4d3ffd6f2f5","analyzedAt":"2026-08-15T12:14:11.722Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}