{"record":{"id":"c5ba824c1c52f603","repo":"larksuite/cli","slug":"download-exceeds-size-limit-max-s","errorCode":null,"errorMessage":"download exceeds size limit (max %s)","messagePattern":"download exceeds size limit \\(max (.+?)\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/im/helpers.go","lineNumber":267,"sourceCode":"\t\tcloser: resp.Body,\n\t\tmax:    maxSize,\n\t}\n\treturn lr, ext, nil\n}\n\n// limitedReadCloser wraps a LimitReader and checks for size overflow on Close.\ntype limitedReadCloser struct {\n\tr      io.Reader\n\tcloser io.Closer\n\tmax    int64\n\tn      int64\n}\n\nfunc (l *limitedReadCloser) Read(p []byte) (int, error) {\n\tn, err := l.r.Read(p)\n\tl.n += int64(n)\n\tif l.n > l.max {\n\t\treturn n, fmt.Errorf(\"download exceeds size limit (max %s)\", common.FormatSize(l.max)) //nolint:forbidigo // io.Reader.Read contract returns a plain error; classified by the download caller\n\t}\n\treturn n, err\n}\n\nfunc (l *limitedReadCloser) Close() error {\n\treturn l.closer.Close()\n}\n\n// mediaKind distinguishes image uploads (image_key) from file uploads (file_key).\ntype mediaKind int\n\nconst (\n\tmediaKindImage mediaKind = iota // upload via image API, returns image_key\n\tmediaKindFile                   // upload via file API, returns file_key\n)\n\n// mediaSpec describes how to resolve and upload a single media input.\ntype mediaSpec struct {","sourceCodeStart":249,"sourceCodeEnd":285,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/im/helpers.go#L249-L285","documentation":"Returned from limitedReadCloser.Read when a download's accumulated bytes exceed maxSize; the reader aborts the transfer so oversized downloads fail fast. Classified by the download caller.","triggerScenarios":"Thrown at shortcuts/im/helpers.go:267 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Exclude the oversized item or raise the download size limit"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7fd6ef3c07182257ce776cdc5a614e122d5bd4b3","analyzedAt":"2026-09-04T21:17:44.649Z","contentChangedAt":"2026-09-04T21:17:44.649Z","schemaVersion":2},"datasetVersion":"2026-09-12T02:17:10.037Z"}