{"record":{"id":"25451b92009c7db0","repo":"lingochamp/FileDownloader","slug":"require-s-with-contentlength-d-but-the-backend","errorCode":null,"errorMessage":"require %s with contentLength(%d), but the backend response contentLength is %d on downloadId[%d]-connectionIndex[%d], please ask your backend dev to fix such problem.","messagePattern":"require (.+?) with contentLength\\((.+?)\\), but the backend response contentLength is (.+?) on downloadId\\[(.+?)\\]-connectionIndex\\[(.+?)\\], please ask your backend dev to fix such problem\\.","errorType":"exception","errorClass":"FileDownloadGiveUpRetryException","httpStatus":null,"severity":"error","filePath":"library/src/main/java/com/liulishuo/filedownloader/download/FetchDataTask.java","lineNumber":104,"sourceCode":"        if (contentLength == TOTAL_VALUE_IN_CHUNKED_RESOURCE) {\n            contentLength = FileDownloadUtils.findContentLengthFromContentRange(connection);\n        }\n        if (contentLength == 0) {\n            throw new FileDownloadGiveUpRetryException(FileDownloadUtils.\n                    formatString(\n                            \"there isn't any content need to download on %d-%d with the \"\n                                    + \"content-length is 0\",\n                            downloadId, connectionIndex));\n        }\n\n        if (this.contentLength > 0 && contentLength != this.contentLength) {\n            final String range;\n            if (endOffset == ConnectionProfile.RANGE_INFINITE) {\n                range = FileDownloadUtils.formatString(\"range[%d-)\", currentOffset);\n            } else {\n                range = FileDownloadUtils.formatString(\"range[%d-%d)\", currentOffset, endOffset);\n            }\n            throw new FileDownloadGiveUpRetryException(FileDownloadUtils.\n                    formatString(\"require %s with contentLength(%d), but the \"\n                                    + \"backend response contentLength is %d on \"\n                                    + \"downloadId[%d]-connectionIndex[%d], please ask your backend \"\n                                    + \"dev to fix such problem.\",\n                            range, this.contentLength, contentLength, downloadId, connectionIndex));\n        }\n\n        final long fetchBeginOffset = currentOffset;\n        // start fetch\n        InputStream inputStream = null;\n        FileDownloadOutputStream outputStream = null;\n\n        try {\n            final boolean isSupportSeek = CustomComponentHolder.getImpl().isSupportSeek();\n            if (hostRunnable != null && !isSupportSeek) {\n                throw new IllegalAccessException(\n                        \"can't using multi-download when the output stream can't support seek\");\n            }","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/lingochamp/FileDownloader/blob/6237a8cac174bcc916e4342b14ab1ab72a5768d4/library/src/main/java/com/liulishuo/filedownloader/download/FetchDataTask.java#L86-L122","documentation":"Error \"require %s with contentLength(%d), but the backend response contentLength is %d on downloadId[%d]-connectionIndex[%d], please ask your backend dev to fix such problem.\" thrown in lingochamp/FileDownloader.","triggerScenarios":"Thrown at library/src/main/java/com/liulishuo/filedownloader/download/FetchDataTask.java:104 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ask the backend/CDN to return a Content-Length consistent with the requested Range (start-end) so the delivered length matches the requested length","Verify the request's Range header and the library-computed startOffset/endOffset are correct (not corrupted by a previous partial download)","Check that no intermediary proxy/cache rewrites the response and strips or alters Content-Length/Content-Range","As a workaround, download the file with a single connection from offset 0 or disable range-based multi-connection download for this URL"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"6237a8cac174bcc916e4342b14ab1ab72a5768d4","analyzedAt":"2026-09-08T23:50:48.168Z","contentChangedAt":"2026-09-08T23:50:48.168Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}