dutchcoders/transfer.sh · error

cannot find file %s/%s

Error message

cannot find file %s/%s

What it means

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).

Source

Thrown at server/storage/gdrive.go:137

		for _, fi := range l.Files {
			tokenID = fi.Id
			break
		}

		if l.NextPageToken == "" {
			break
		}

		l, err = s.list(l.NextPageToken, q)
		if err != nil {
			return "", err
		}
	}

	if filename == "" {
		return tokenID, nil
	} else if tokenID == "" {
		return "", fmt.Errorf("cannot find file %s/%s", token, filename)
	}

	q = fmt.Sprintf("'%s' in parents and name='%s' and mimeType!='%s' and trashed=false", tokenID, filename, gDriveDirectoryMimeType)
	l, err = s.list(nextPageToken, q)
	if err != nil {
		return "", err
	}

	for 0 < len(l.Files) {
		for _, fi := range l.Files {

			fileID = fi.Id
			break
		}

		if l.NextPageToken == "" {
			break
		}

View on GitHub (pinned to c37bfd9579)

Solutions

  1. Verify the token and filename in the request exactly match the upload (exact name match, no case or space differences).
  2. Check in the Google Drive UI (under the basedir folder) that the file still exists and was not trashed or moved.
  3. Confirm the backend is authenticated against the same Drive account that holds the upload (client JSON / local config credentials).
  4. Re-upload the file if it was removed; for Put failures, ensure the token folder was created successfully before writing the file.

Example fix

// before
curl -OJ https://host/AbCdEf/report.pdf   # actual name: Report.pdf
// after
curl -OJ https://host/AbCdEf/Report.pdf   # exact Drive filename
Defensive patterns

Strategy: validation

Validate before calling

// HEAD before GET to confirm the file resolves in Drive storage
resp, _ := http.Head(fmt.Sprintf("https://host/%s/%s", token, filename))
if resp.StatusCode == http.StatusNotFound {
	// file missing: re-upload or correct the filename
}

Try / catch

resp, err := http.Get(url)
if err == nil && resp.StatusCode != http.StatusOK {
	b, _ := io.ReadAll(resp.Body)
	if strings.Contains(string(b), "cannot find file") {
		// verify token/filename against the upload receipt, then re-upload if needed
	}
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of dutchcoders/transfer.sh@c37bfd9579 (2026-09-05). Data as JSON: /api/errors/3f1d938a805d95fe. Report an issue: GitHub.