{"record":{"id":"58b03363f26204f3","repo":"AlistGo/alist","slug":"invalid-auth-type","errorCode":null,"errorMessage":"invalid auth_type","messagePattern":"invalid auth_type","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"drivers/yunpan360/driver.go","lineNumber":87,"sourceCode":"\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 {\n\td.cachedOpenAuth = nil\n\td.openAuthExpire = time.Time{}\n\td.cachedCookieSession = nil\n\td.cookieSessionExpire = time.Time{}\n\treturn nil\n}\n\nfunc (d *Yunpan360) List(ctx context.Context, dir model.Obj, args model.ListArgs) ([]model.Obj, error) {\n\tdirPath := dir.GetPath()\n\tif dirPath == \"\" {\n\t\tdirPath = d.RootFolderPath\n\t}\n\n\tobjs := make([]model.Obj, 0, d.PageSize)","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/AlistGo/alist/blob/843d9dc8149126976b2625911e45a4d3ffd6f2f5/drivers/yunpan360/driver.go#L69-L105","documentation":"Thrown by Yunpan360 Init()'s switch default when d.authMode() returns something other than \"api_key\" or \"cookie\". In the current code this is effectively unreachable: Init lowercases and defaults an empty AuthType to cookie, and authMode() returns api_key only when AuthType==\"api_key\", cookie otherwise. It is a defensive guard against future auth modes or a corrupted AuthType value (e.g. injected mid-struct without going through Init normalization).","triggerScenarios":"Calling driver methods on a Yunpan360 instance whose AuthType was set directly to an unrecognized value without running Init(); a future driver version adds a third auth mode but this switch wasn't updated.","commonSituations":"Programmatic use of the driver outside AList's config flow; hand-crafted driver structs in tests; merged configs from a forked driver exposing extra auth types.","solutions":["Set auth_type to exactly \"cookie\" or \"api_key\" (the values in meta.go options) and re-init","If constructing the driver in code, go through Init() so empty/odd values get normalized","On a fork adding a new auth mode, add the matching case to this switch"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"t := strings.ToLower(strings.TrimSpace(cfg.AuthType))\nif t != \"\" && t != \"cookie\" && t != \"api_key\" {\n    return fmt.Errorf(\"auth_type must be cookie or api_key, got %q\", cfg.AuthType)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Restrict auth_type to the two documented options","Construct the driver through Init() so values get normalized","On forks adding auth modes, extend the driver switch"],"tags":["yunpan360","driver","config","auth","defensive-guard"],"backgroundTag":null,"analyzedSha":"843d9dc8149126976b2625911e45a4d3ffd6f2f5","analyzedAt":"2026-08-15T12:14:11.722Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}