{"record":{"id":"8b31b2ac6384deab","repo":"IceWhaleTech/CasaOS","slug":"s-v-8b31b2","errorCode":null,"errorMessage":"%s: %v","messagePattern":"%s: %v","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/google_drive/drive.go","lineNumber":173,"sourceCode":"\t\t}).\n\t\tSetError(&e).SetBody(data).SetContext(ctx)\n\tif obj != nil {\n\t\tres, err = req.Patch(url)\n\t} else {\n\t\tres, err = req.Post(url)\n\t}\n\tif err != nil {\n\t\treturn err\n\t}\n\tif e.Error.Code != 0 {\n\t\tif e.Error.Code == 401 {\n\t\t\terr = d.refreshToken()\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\treturn d.Put(ctx, dstDir, stream, up)\n\t\t}\n\t\treturn fmt.Errorf(\"%s: %v\", e.Error.Message, e.Error.Errors)\n\t}\n\tputUrl := res.Header().Get(\"location\")\n\tif stream.GetSize() < d.ChunkSize*1024*1024 {\n\t\t_, err = d.request(putUrl, http.MethodPut, func(req *resty.Request) {\n\t\t\treq.SetHeader(\"Content-Length\", strconv.FormatInt(stream.GetSize(), 10)).SetBody(stream.GetReadCloser())\n\t\t}, nil)\n\t} else {\n\t\terr = d.chunkUpload(ctx, stream, putUrl)\n\t}\n\treturn err\n}\n\nvar _ driver.Driver = (*GoogleDrive)(nil)\n","sourceCodeStart":155,"sourceCodeEnd":187,"githubUrl":"https://github.com/IceWhaleTech/CasaOS/blob/0d3b2f444ec0193193cf03eef6d43c6e35b0183e/drivers/google_drive/drive.go#L155-L187","documentation":"During a Google Drive upload (Put), the resumable-session initiation or a follow-up call returned an error body with a non-zero code other than 401; the driver formats the API's message and Errors details as '%s: %v'. The 401 branch refreshes the token and re-enters Put; all other codes fail with this message.","triggerScenarios":"Initiating a resumable upload or PUT-ing bytes when storage quota is exceeded (403 storageQuotaExceeded), the parent folder is gone (404), permission scopes are insufficient, the file exceeds Google Drive size limits, or the upload session timed out.","commonSituations":"Google account out of storage; OAuth consent missing Drive scope after an app-scope change; uploading to a shared folder the token's account cannot write; resuming a session URL that expired (must restart within ~1 week, chunk gaps).","solutions":["Match the message/errors against the Google Drive API error table — the reason string (e.g. 'storageQuotaExceeded', 'notFound') names the fix.","Check account storage at https://one.google.com/storage and free space or upgrade if quota is exceeded.","Verify the OAuth scopes granted to the token include drive scope; re-authorize after changing scopes.","For large files, ensure chunk uploads are contiguous and the session is completed within its validity."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"err := d.Put(ctx, dstDir, stream, up)\nif err != nil {\n\tmsg := err.Error()\n\tswitch {\n\tcase strings.Contains(msg, \"storageQuotaExceeded\"):\n\t\treturn errors.New(\"Google Drive storage is full; free space and retry\")\n\tcase strings.Contains(msg, \"notFound\"):\n\t\treturn refreshParentAndRetry()\n\t}\n\treturn err\n}","preventionTips":["Check available quota before large uploads","Keep resumable sessions short-lived and complete chunks contiguously","Re-authorize whenever Drive scopes change in the consent screen"],"tags":["google-drive","upload","api-error","quota"],"backgroundTag":null,"analyzedSha":"0d3b2f444ec0193193cf03eef6d43c6e35b0183e","analyzedAt":"2026-08-15T13:27:57.821Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}