{"record":{"id":"f1de9359169cff87","repo":"AlistGo/alist","slug":"oss-chunknum-invalid","errorCode":null,"errorMessage":"oss: chunkNum invalid","messagePattern":"oss: chunkNum invalid","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/115/util.go","lineNumber":529,"sourceCode":"\t}\n\t// 单个分片大小不能小于100KB\n\tif chunks[0].Size < 100*utils.KB {\n\t\tif chunks, err = SplitFileByPartSize(fileSize, 100*utils.KB); err != nil {\n\t\t\treturn\n\t\t}\n\t}\n\treturn\n}\n\n// SplitFileByPartNum splits big file into parts by the num of parts.\n// Split the file with specified parts count, returns the split result when error is nil.\nfunc SplitFileByPartNum(fileSize int64, chunkNum int) ([]oss.FileChunk, error) {\n\tif chunkNum <= 0 || chunkNum > 10000 {\n\t\treturn nil, errors.New(\"chunkNum invalid\")\n\t}\n\n\tif int64(chunkNum) > fileSize {\n\t\treturn nil, errors.New(\"oss: chunkNum invalid\")\n\t}\n\n\tvar chunks []oss.FileChunk\n\tchunk := oss.FileChunk{}\n\tchunkN := (int64)(chunkNum)\n\tfor i := int64(0); i < chunkN; i++ {\n\t\tchunk.Number = int(i + 1)\n\t\tchunk.Offset = i * (fileSize / chunkN)\n\t\tif i == chunkN-1 {\n\t\t\tchunk.Size = fileSize/chunkN + fileSize%chunkN\n\t\t} else {\n\t\t\tchunk.Size = fileSize / chunkN\n\t\t}\n\t\tchunks = append(chunks, chunk)\n\t}\n\n\treturn chunks, nil\n}","sourceCodeStart":511,"sourceCodeEnd":547,"githubUrl":"https://github.com/AlistGo/alist/blob/843d9dc8149126976b2625911e45a4d3ffd6f2f5/drivers/115/util.go#L511-L547","documentation":"Raised by Streamtape.callAPI (drivers/streamtape/util.go:41) when the HTTP response status from api.streamtape.com is anything other than 200, before the JSON envelope is inspected. It signals transport/auth-level failure at the HTTP layer (e.g. 401/403 bad key, 404 wrong endpoint, 429/5xx upstream issues), not a Streamtape business error.","triggerScenarios":"Any driver API call (list, file/info, remotedl/*, getsplash) where the server or an intermediate proxy returns a non-200 status: invalid or revoked login key (401/403), rate limiting (429), Cloudflare/CDN block page (403/503), or a temporary outage (5xx).","commonSituations":"Expired Streamtape account API key configured for the storage; IP blocked or rate-limited after aggressive polling (e.g. remoteDlStatus loops); endpoint paths changed after a Streamtape API revision; restrictive corporate proxy rewriting responses.","solutions":["Verify the stored Streamtape credentials (login/account key) and re-authenticate the storage if needed.","Retry with backoff for 429/5xx — these are typically transient.","Log the status code together with the endpoint to distinguish auth (401/403) from capacity (429/5xx), and check Streamtape status/API docs if it persists on all endpoints.","If a proxy is in the path, bypass it or add proper exceptions for api.streamtape.com."],"exampleFix":"// before: call once, fail hard on first 429/503\nres, err := d.callAPI(ctx, \"/file/info\", q, &out)\n\n// after: retry transient statuses\nvar out fileInfoResult\nerr := retryOnTransient(func() error {\n\te := d.callAPI(ctx, \"/file/info\", q, &out)\n\tif e != nil && isRetryableStreamtapeHTTP(e) {\n\t\treturn e\n\t}\n\treturn retry.Stop(e)\n})","handlingStrategy":"retry","validationCode":"// optional pre-flight: cheap endpoint probe\nvar probe struct{}\nif err := d.callAPI(ctx, \"/account/info\", map[string]string{}, &probe); err != nil {\n\t// surface credentials/network problem before the real operation\n}","typeGuard":null,"tryCatchPattern":"var lastErr error\nfor i := 0; i < 3; i++ {\n\tlastErr = d.callAPI(ctx, endpoint, query, out)\n\tif lastErr == nil || !isRetryableStreamtapeHTTP(lastErr) {\n\t\tbreak\n\t}\n\ttime.Sleep(time.Duration(i+1) * time.Second)\n}\n// isRetryableStreamtapeHTTP: status 429 or 5xx parsed from the error string","preventionTips":["Keep Streamtape credentials current; rotate on 401/403.","Rate-limit polling loops (remoteDlStatus) to avoid 429.","Log status code + endpoint to distinguish auth from capacity failures."],"tags":["streamtape","http","upstream","auth"],"backgroundTag":null,"analyzedSha":"843d9dc8149126976b2625911e45a4d3ffd6f2f5","analyzedAt":"2026-08-15T12:14:11.722Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}