{"record":{"id":"c327218a4152276a","repo":"duplicati/duplicati","slug":"invalid-file-size-for-remotename","errorCode":null,"errorMessage":"Invalid file size for {remotename}","messagePattern":"Invalid file size for (.+?)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"Duplicati/Library/Backend/Jottacloud/Jottacloud.cs","lineNumber":468,"sourceCode":"\n        await using var s = await response.Content.ReadAsStreamAsync(cancelToken).ConfigureAwait(false);\n        await using var t = s.ObserveReadTimeout(m_timeouts.ReadWriteTimeout);\n        await Utility.Utility.CopyStreamAsync(s, stream, true, cancelToken).ConfigureAwait(false);\n    }\n\n    /// <summary>\n    /// Fetches the file in chunks (parallelized)\n    /// </summary>\n    private async Task ParallelGetAsync(string remotename, Stream stream, CancellationToken cancelToken)\n    {\n        // Get file info and validate\n        var info = await Info(remotename, cancelToken).ConfigureAwait(false);\n        if (info == null)\n            throw new FileMissingException(remotename);\n\n        var size = info.Size;\n        if (size < 0)\n            throw new InvalidOperationException($\"Invalid file size for {remotename}\");\n\n        // Calculate chunks with bounds checking\n        var chunks = new Queue<(long start, long end)>();\n        long position = 0;\n        while (position < size)\n        {\n            var length = Math.Min(m_chunksize, size - position);\n            if (length <= 0)\n                throw new InvalidOperationException($\"Invalid chunk length calculated for {remotename}\");\n            chunks.Enqueue((position, position + length));\n            position += length;\n        }\n\n        var tasks = new List<Task<(byte[] buffer, long start, Exception? error)>>();\n        var completedChunks = new SortedDictionary<long, byte[]>();\n        var semaphore = new SemaphoreSlim(m_threads, m_threads);\n        long nextWritePosition = 0;\n","sourceCodeStart":450,"sourceCodeEnd":486,"githubUrl":"https://github.com/duplicati/duplicati/blob/3f348be3e33f5d72d414e3ad55839c2ba34dda67/Duplicati/Library/Backend/Jottacloud/Jottacloud.cs#L450-L486","documentation":"Thrown in ParallelGetAsync when info.Size is negative. ToFileEntry sets size to -1 when the <size> element is missing or not a parseable long, so a < 0 size means the file metadata is absent or corrupt.","triggerScenarios":"The file's currentRevision XML lacks a <size> child or contains a non-numeric <size>, causing ToFileEntry to default size to -1, which then fails the size >= 0 guard before chunking.","commonSituations":"Server-side metadata corruption; the file is in an unusual state (e.g. only a corrupt latestRevision); a JFS API response-format change dropped or renamed the size element.","solutions":["Re-upload the file to regenerate clean metadata.","Fall back to single-threaded download (jottacloud-threads=1) which does not need the size for chunking.","Inspect the raw XML for the file via a direct JFS GET to confirm the size element."],"exampleFix":"// before\n--jottacloud-threads=4  // ParallelGetAsync needs a valid size\n// after\n--jottacloud-threads=1  // GetAsync streams without chunk math","handlingStrategy":"fallback","validationCode":"// Prefer single-threaded get when file metadata is unreliable\nif (threads <= 1) await backend.GetAsync(name, dest, token); // streams without size math","typeGuard":null,"tryCatchPattern":"try { await backend.GetAsync(remotename, dest, token); /* threads > 1 */ }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"Invalid file size\"))\n{\n    // fall back to single-threaded streaming download that does not need the size\n}","preventionTips":["Set jottacloud-threads=1 for files with unreliable or missing size metadata.","Re-upload files whose <size> metadata is absent or corrupt.","Inspect the raw JFS XML for the file to confirm the size element before chunking."],"tags":["jottacloud","metadata","download"],"backgroundTag":null,"analyzedSha":"3f348be3e33f5d72d414e3ad55839c2ba34dda67","analyzedAt":"2026-08-13T16:48:27.008Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}