{"record":{"id":"5a9bb0337bac7f1c","repo":"chenhg5/cc-connect","slug":"get-file-w","errorCode":null,"errorMessage":"get file: %w","messagePattern":"get file: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"platform/telegram/telegram.go","lineNumber":1353,"sourceCode":"\tif err != nil {\n\t\treturn err\n\t}\n\t_, err = bot.DeleteMessage(ctx, &tgbot.DeleteMessageParams{ChatID: h.chatID, MessageID: h.messageID})\n\tif err != nil {\n\t\tslog.Debug(\"telegram: delete preview message failed\", \"error\", err)\n\t}\n\treturn err\n}\n\nfunc (p *Platform) downloadFile(fileID string) ([]byte, error) {\n\tbot, err := p.connectedBot(\"download file\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tctx := context.Background()\n\tf, err := bot.GetFile(ctx, &tgbot.GetFileParams{FileID: fileID})\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"get file: %w\", err)\n\t}\n\tif f.FilePath == \"\" {\n\t\treturn nil, fmt.Errorf(\"get file: empty file_path returned for file_id %s\", fileID)\n\t}\n\tlink := bot.FileDownloadLink(f)\n\n\tresp, err := p.httpClient.Get(link)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"download file %s: %w\", fileID, err)\n\t}\n\tdefer resp.Body.Close()\n\tif resp.StatusCode != http.StatusOK {\n\t\treturn nil, fmt.Errorf(\"download file %s: status %d\", fileID, resp.StatusCode)\n\t}\n\treturn io.ReadAll(resp.Body)\n}\n\nfunc (p *Platform) ReconstructReplyCtx(sessionKey string) (any, error) {","sourceCodeStart":1335,"sourceCodeEnd":1371,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/platform/telegram/telegram.go#L1335-L1371","documentation":"Returned when bot.GetFile — the Telegram Bot API getFile call used to resolve a file_id into a downloadable path — fails. The error wraps the underlying Bot API/network error, meaning the platform could not obtain file metadata for the requested file.","triggerScenarios":"In the file download helper, bot.GetFile(ctx, &tgbot.GetFileParams{FileID: fileID}) returns a non-nil err (invalid file_id, file too large for bots, network failure).","commonSituations":"Passing a file_id from a different bot (file_ids are bot-scoped); file larger than the 20 MB bot download limit; expired media group reference; Telegram API outage.","solutions":["Verify the file_id belongs to the same bot token performing the getFile call.","Check file size — bots can only download files up to 20 MB via getFile; use a local Bot API server for larger files.","Confirm network connectivity to api.telegram.org and retry transient errors.","Read the wrapped Bot API description ('wrong file identifier') to distinguish bad ID from size limits."],"exampleFix":"// before\nf, err := bot.GetFile(ctx, &tgbot.GetFileParams{FileID: fileID})\n// after: validate before calling\nif fileID == \"\" { return nil, errors.New(\"empty file_id\") }\nf, err := bot.GetFile(ctx, &tgbot.GetFileParams{FileID: fileID})","handlingStrategy":"validation","validationCode":"if fileID == \"\" { return errors.New(\"empty file_id\") }","typeGuard":null,"tryCatchPattern":"f, err := bot.GetFile(ctx, &tgbot.GetFileParams{FileID: fileID})\nif err != nil {\n    return nil, fmt.Errorf(\"get file: %w\", err) // inspect wrapped Bot API reason\n}","preventionTips":["Only use file_ids issued to the same bot token","Check file size ≤20 MB for bot downloads","Retry transient Telegram API failures","Log the wrapped Bot API description for diagnosis"],"tags":["telegram","bot-api","getfile","file-download"],"backgroundTag":"file-download-failed","analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}