{"record":{"id":"94779e05eed28210","repo":"AlistGo/alist","slug":"gofile-api-error-http-d-s","errorCode":null,"errorMessage":"gofile API error: HTTP %d - %s","messagePattern":"gofile API error: HTTP (.+?) - (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/gofile/util.go","lineNumber":149,"sourceCode":"\tdefer resp.Body.Close()\n\n\tif resp.StatusCode != http.StatusOK {\n\t\treturn d.handleError(resp)\n\t}\n\n\treturn nil\n}\n\nfunc (d *Gofile) handleError(resp *http.Response) error {\n\tbody, _ := io.ReadAll(resp.Body)\n\tlog.Debugf(\"Gofile API error (HTTP %d): %s\", resp.StatusCode, string(body))\n\n\tvar errorResp ErrorResponse\n\tif err := json.Unmarshal(body, &errorResp); err == nil && errorResp.Status == \"error\" {\n\t\treturn fmt.Errorf(\"gofile API error: %s (code: %s)\", errorResp.Error.Message, errorResp.Error.Code)\n\t}\n\n\treturn fmt.Errorf(\"gofile API error: HTTP %d - %s\", resp.StatusCode, string(body))\n}\n\nfunc (d *Gofile) uploadFile(ctx context.Context, folderId string, file model.FileStreamer, up driver.UpdateProgress) (*UploadResponse, error) {\n\tvar body bytes.Buffer\n\twriter := multipart.NewWriter(&body)\n\n\tif folderId != \"\" {\n\t\twriter.WriteField(\"folderId\", folderId)\n\t}\n\n\tpart, err := writer.CreateFormFile(\"file\", filepath.Base(file.GetName()))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Copy with progress tracking if available\n\tif up != nil {\n\t\treader := &progressReader{","sourceCodeStart":131,"sourceCodeEnd":167,"githubUrl":"https://github.com/AlistGo/alist/blob/843d9dc8149126976b2625911e45a4d3ffd6f2f5/drivers/gofile/util.go#L131-L167","documentation":"Fallback Gofile API error: the response body did not parse as a Gofile error JSON (or status was not 'error'), so the driver returns 'gofile API error: HTTP <status> - <raw body>'. This is the path for HTML error pages, gateway errors, and non-JSON responses.","triggerScenarios":"Gofile behind Cloudflare returning a 502/504 HTML page; 5xx from api.gofile.io; body truncated by a proxy so json.Unmarshal fails; unexpected content-type on an endpoint.","commonSituations":"Temporary outage or maintenance of gofile.io; corporate proxy intercepting TLS and returning its own error page; CDN rate-limit challenge (HTML) instead of API JSON.","solutions":["Read the HTTP status: 5xx -> transient, retry later; 4xx -> inspect raw body in the message for proxy/auth hints","Test connectivity: curl -i https://api.gofile.io/getServer directly from the host","Bypass interfering proxies / fix TLS interception for api.gofile.io","Retry after the service recovers; no client-side config change fixes a 5xx"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":"func isTransientGofileHTTPError(err error) bool {\n  return err != nil && strings.Contains(err.Error(), \"HTTP 5\") && strings.Contains(err.Error(), \"gofile API error\")\n}","tryCatchPattern":"err := op.Do()\nif err != nil && isTransientGofileHTTPError(err) {\n  // exponential backoff retry; give up after N attempts\n}","preventionTips":["Retry only 5xx with backoff; treat 4xx bodies as configuration or proxy issues","Whitelist api.gofile.io through TLS-intercepting proxies"],"tags":["gofile","api","http","gateway","network"],"backgroundTag":null,"analyzedSha":"843d9dc8149126976b2625911e45a4d3ffd6f2f5","analyzedAt":"2026-08-15T12:14:11.722Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}