{"record":{"id":"3f1d938a805d95fe","repo":"dutchcoders/transfer.sh","slug":"cannot-find-file-s-s","errorCode":null,"errorMessage":"cannot find file %s/%s","messagePattern":"cannot find file (.+?)/(.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/storage/gdrive.go","lineNumber":137,"sourceCode":"\t\tfor _, fi := range l.Files {\n\t\t\ttokenID = fi.Id\n\t\t\tbreak\n\t\t}\n\n\t\tif l.NextPageToken == \"\" {\n\t\t\tbreak\n\t\t}\n\n\t\tl, err = s.list(l.NextPageToken, q)\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t}\n\n\tif filename == \"\" {\n\t\treturn tokenID, nil\n\t} else if tokenID == \"\" {\n\t\treturn \"\", fmt.Errorf(\"cannot find file %s/%s\", token, filename)\n\t}\n\n\tq = fmt.Sprintf(\"'%s' in parents and name='%s' and mimeType!='%s' and trashed=false\", tokenID, filename, gDriveDirectoryMimeType)\n\tl, err = s.list(nextPageToken, q)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tfor 0 < len(l.Files) {\n\t\tfor _, fi := range l.Files {\n\n\t\t\tfileID = fi.Id\n\t\t\tbreak\n\t\t}\n\n\t\tif l.NextPageToken == \"\" {\n\t\t\tbreak\n\t\t}","sourceCodeStart":119,"sourceCodeEnd":155,"githubUrl":"https://github.com/dutchcoders/transfer.sh/blob/c37bfd95797fd6da8a6da53fc13d191994b3f687/server/storage/gdrive.go#L119-L155","documentation":"The Google Drive storage backend resolves token/filename to Drive file IDs via findID. It first looks up the folder (token); if the folder ID is empty or no child file with the requested name exists, Put/Get/Head/Delete fail with 'cannot find file token/filename'. It means the corresponding Drive folder or file is missing (never uploaded, deleted, or moved out of the folder).","triggerScenarios":"Get/Head/Delete/Put on a token whose Drive folder contains no file named <filename>, or whose token folder itself doesn't resolve to an ID (tokenID == \"\") — e.g. wrong token in URL, file renamed in the Drive UI, or file trashed.","commonSituations":"File manually deleted or moved within Google Drive by an admin; using a token from a different environment/account than the one the backend is authenticated against; filename case/whitespace mismatch since the Drive query matches name exactly; Drive API pagination/token expiry masking existing files.","solutions":["Verify the token and filename in the request exactly match the upload (exact name match, no case or space differences).","Check in the Google Drive UI (under the basedir folder) that the file still exists and was not trashed or moved.","Confirm the backend is authenticated against the same Drive account that holds the upload (client JSON / local config credentials).","Re-upload the file if it was removed; for Put failures, ensure the token folder was created successfully before writing the file."],"exampleFix":"// before\ncurl -OJ https://host/AbCdEf/report.pdf   # actual name: Report.pdf\n// after\ncurl -OJ https://host/AbCdEf/Report.pdf   # exact Drive filename","handlingStrategy":"validation","validationCode":"// HEAD before GET to confirm the file resolves in Drive storage\nresp, _ := http.Head(fmt.Sprintf(\"https://host/%s/%s\", token, filename))\nif resp.StatusCode == http.StatusNotFound {\n\t// file missing: re-upload or correct the filename\n}","typeGuard":null,"tryCatchPattern":"resp, err := http.Get(url)\nif err == nil && resp.StatusCode != http.StatusOK {\n\tb, _ := io.ReadAll(resp.Body)\n\tif strings.Contains(string(b), \"cannot find file\") {\n\t\t// verify token/filename against the upload receipt, then re-upload if needed\n\t}\n}","preventionTips":["Keep exact filenames (case, spaces) between upload and download URLs.","Don't move or rename files in the Google Drive folder backing the service.","Ensure the Drive credentials match the account that performed the uploads."],"tags":["gdrive","storage","not-found","file-transfer"],"backgroundTag":"resource-not-found","analyzedSha":"c37bfd95797fd6da8a6da53fc13d191994b3f687","analyzedAt":"2026-09-05T10:21:07.548Z","contentChangedAt":"2026-09-05T10:21:07.548Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}