dutchcoders/transfer.sh · error
Could not retrieve file.
Error message
Could not retrieve file.
What it means
When s.storage.Get fails with any error other than not-exist, zipHandler logs it and returns HTTP 500 'Could not retrieve file.'. The storage backend failed to open/read the object for an infrastructural reason rather than because the file is absent.
Source
Thrown at server/handlers.go:1000
token := strings.Split(key, "/")[0]
filename := sanitize(strings.Split(key, "/")[1])
if _, err := s.checkMetadata(r.Context(), token, filename, true); err != nil {
s.logger.Printf("Error metadata: %s", err.Error())
continue
}
reader, _, err := s.storage.Get(r.Context(), token, filename, nil)
defer storage.CloseCheck(reader)
if err != nil {
if s.storage.IsNotExist(err) {
http.Error(w, "File not found", 404)
return
}
s.logger.Printf("%s", err.Error())
http.Error(w, "Could not retrieve file.", http.StatusInternalServerError)
return
}
header := &zip.FileHeader{
Name: strings.Split(key, "/")[1],
Method: zip.Store,
Modified: time.Now().UTC(),
}
fw, err := zw.CreateHeader(header)
if err != nil {
s.logger.Printf("%s", err.Error())
http.Error(w, "Internal server error.", http.StatusInternalServerError)
return
}
View on GitHub (pinned to c37bfd9579)
Solutions
- Inspect the server log line emitted just before the 500 — it contains the real backend error.
- Validate storage backend credentials and network reachability from the server host.
- Check filesystem permissions on the storage directory for the server process.
- Retry the download; if correlated with timeouts, increase the storage client timeout.
Example fix
// before
http.Error(w, "Could not retrieve file.", http.StatusInternalServerError)
// after
s.logger.Printf("zip get %s/%s: %v", token, filename, err)
http.Error(w, "Could not retrieve file.", http.StatusInternalServerError) Defensive patterns
Strategy: retry
Validate before calling
// Check storage reachability before bulk archive downloads:
resp, err := http.Get(healthEndpoint) // or HEAD a known file
if err != nil { /* backend unreachable: GETs will 500 */ } Try / catch
// 500 on retrieve = backend error: retry with backoff, then check server logs
for i := 0; i < 3; i++ {
resp, err := download()
if err == nil && resp.StatusCode == 200 { break }
time.Sleep(backoff(i))
} Prevention
- Monitor storage backend health (disk space, connectivity, credential validity).
- Use generous storage client timeouts for large files.
- Alert on server log lines preceding 500s — they carry the root cause.
- Verify IAM/ACL permissions after any credential rotation.
When it happens
Trigger: s.storage.Get returns a non-IsNotExist error: backend unreachable, invalid credentials, permission denied on the file/directory, context deadline exceeded, or disk I/O error while opening the object.
Common situations: S3/GCS credentials rotated or revoked; storage volume full or failing; firewall blocking the object-store endpoint; client disconnecting and canceling the request before Get completed.
Related errors
- Could not delete file.
- could not save metadata
- metadata doesn't exist
- cannot find file %s/%s
- Could not save metadata
AI-assisted analysis of dutchcoders/transfer.sh@c37bfd9579 (2026-09-05).
Data as JSON: /api/errors/5159afc319bc3609.
Report an issue: GitHub.