{"record":{"id":"67df838272695fe5","repo":"larksuite/cli","slug":"invalid-total-size-d","errorCode":null,"errorMessage":"invalid total size: %d","messagePattern":"invalid total size: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"extension/download/download.go","lineNumber":705,"sourceCode":"\t}\n\tbounds := strings.SplitN(parts[0], \"-\", 2)\n\tif len(bounds) != 2 || bounds[0] == \"\" || bounds[1] == \"\" {\n\t\treturn contentRange{}, fmt.Errorf(\"unsupported content-range: %q\", header)\n\t}\n\tstart, err := strconv.ParseInt(bounds[0], 10, 64)\n\tif err != nil {\n\t\treturn contentRange{}, fmt.Errorf(\"parse range start: %w\", err)\n\t}\n\tend, err := strconv.ParseInt(bounds[1], 10, 64)\n\tif err != nil {\n\t\treturn contentRange{}, fmt.Errorf(\"parse range end: %w\", err)\n\t}\n\ttotal, err := strconv.ParseInt(parts[1], 10, 64)\n\tif err != nil {\n\t\treturn contentRange{}, fmt.Errorf(\"parse total size: %w\", err)\n\t}\n\tif total <= 0 {\n\t\treturn contentRange{}, fmt.Errorf(\"invalid total size: %d\", total)\n\t}\n\tif start < 0 || end < 0 {\n\t\treturn contentRange{}, fmt.Errorf(\"invalid negative content range: %d-%d\", start, end)\n\t}\n\tif start > end {\n\t\treturn contentRange{}, fmt.Errorf(\"invalid content range: start %d is after end %d\", start, end)\n\t}\n\tif end >= total {\n\t\treturn contentRange{}, fmt.Errorf(\"invalid content range: end %d is outside total %d\", end, total)\n\t}\n\treturn contentRange{start: start, end: end, total: total}, nil\n}\n\n// strongETag returns a validator suitable for If-Range.\nfunc strongETag(header http.Header) (string, bool) {\n\tvalues := header.Values(\"ETag\")\n\tif len(values) != 1 {\n\t\treturn \"\", false","sourceCodeStart":687,"sourceCodeEnd":723,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/extension/download/download.go#L687-L723","documentation":"The Content-Range total parsed successfully but was zero or negative, which is impossible for a real resource. The library rejects it because range math and completeness checks depend on a positive total size.","triggerScenarios":"openPartial or openNext received e.g. 'bytes 0-0/0' or 'bytes 0-99/-1'.","commonSituations":"Empty/dynamically generated objects with bogus metadata; servers with uninitialized size fields; broken mock servers.","solutions":["Verify the object actually exists and has a positive size on the storage backend.","Fix the server's size reporting (Content-Length/Content-Range).","Re-upload or recreate the object if its metadata is corrupt.","Use a plain GET without Range for empty or dynamically sized resources."],"exampleFix":"// before\n// Content-Range: bytes 0-0/0\n// after\n// Content-Range: bytes 0-0/1","handlingStrategy":"validation","validationCode":"func positiveTotal(h string) bool {\n\t_, spec, _ := strings.Cut(h, \" \")\n\t_, total, _ := strings.Cut(spec, \"/\")\n\tn, err := strconv.ParseInt(total, 10, 64)\n\treturn err == nil && n > 0\n}","typeGuard":null,"tryCatchPattern":"cr, err := parseContentRange(header)\nif err != nil {\n\t// bogus total: fetch full body without Range\n\treturn downloadFull(ctx, url)\n}","preventionTips":["Verify objects exist with positive size before downloading","Fix server size metadata; check Content-Length > 0","Re-upload objects with corrupt metadata"],"tags":["http","content-range","download"],"backgroundTag":"invalid-content-range-header","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"}