{"record":{"id":"df6d41c349bc067b","repo":"xpipe-io/xpipe","slug":"source-file-sourcefile-input-size-mismatch-exp","errorCode":null,"errorMessage":"Source file ${sourceFile} input size mismatch: Expected ${expected} but got ${actual}. Did the source file get updated?","messagePattern":"Source file (.+?) input size mismatch: Expected (.+?) but got (.+?)\\. Did the source file get updated\\?","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"app/src/main/java/io/xpipe/app/browser/file/BrowserFileTransferOperation.java","lineNumber":622,"sourceCode":"                        killStreams.set(true);\n                        break;\n                    }\n\n                    outputStream.write(buffer, 0, read);\n                    transferred.addAndGet(read);\n                    readCount.addAndGet(read);\n                    if (reportProgress) {\n                        updateProgress(\n                                new BrowserTransferProgress(sourceFile.getFileName(), transferred.get(), total.get()));\n                    }\n                }\n\n                outputStream.flush();\n                inputStream.transferTo(OutputStream.nullOutputStream());\n\n                var incomplete = !killStreams.get() && readCount.get() < expectedFileSize;\n                if (incomplete) {\n                    throw new IOException(\"Source file \" + sourceFile + \" input size mismatch: Expected \"\n                            + expectedFileSize + \" but got \" + readCount.get() + \". Did the source file get updated?\");\n                }\n            } catch (Exception ex) {\n                exception.set(ex);\n                killStreams.set(true);\n            }\n        });\n\n        thread.start();\n        while (true) {\n            var alive = thread.isAlive();\n            var cancelled = cancelled();\n\n            if (cancelled) {\n                killStreams(thread, readCount, false);\n                break;\n            }\n","sourceCodeStart":604,"sourceCodeEnd":640,"githubUrl":"https://github.com/xpipe-io/xpipe/blob/d85ca821baa46092a320ebb13546d7240adb74f8/app/src/main/java/io/xpipe/app/browser/file/BrowserFileTransferOperation.java#L604-L640","documentation":"Thrown during transferFile when the number of bytes actually read from the source file is less than the expected file size recorded when the transfer was planned. The operation treats a short read as corruption risk and kills the streams, wrapping it in an IOException.","triggerScenarios":"The source file shrunk or was truncated/rewritten between size capture and streaming, or the underlying stream ended early (network drop, remote process writing the file concurrently).","commonSituations":"Transferring log files actively being rotated or truncated, files modified by a running job on the remote host, unstable SSH/network connections terminating the stream early.","solutions":["Retry the transfer after the source file stops changing","Exclude actively written files (logs, temp files) from the transfer","Snapshot/quiesce the source (stop the writer) before transferring","Verify connection stability to the remote system and retry"],"exampleFix":"// before\ntransferFiles(List.of(\"/var/log/app.log\")) // file being actively written\n// after\n// copy or rotate the log first, then transfer the static file\ntransferFiles(List.of(\"/var/log/app.log.1\"))","handlingStrategy":"retry","validationCode":"async function transferStable(transfer, files, retries = 2) {\n  for (let i = 0; i <= retries; i++) {\n    try { return await transfer(files); }\n    catch (e) {\n      if (!String(e.message).includes('size mismatch') || i === retries) throw e;\n    }\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  await transferFiles(files);\n} catch (e) {\n  if (String(e.message).includes('size mismatch')) {\n    // source changed mid-transfer; quiesce writer and retry\n  }\n}","preventionTips":["Exclude actively written files (logs, temp files) from transfers","Stop writers / rotate logs before transferring","Retry on unstable remote connections"],"tags":["transfer","filesystem","io"],"backgroundTag":"checksum-mismatch","analyzedSha":"d85ca821baa46092a320ebb13546d7240adb74f8","analyzedAt":"2026-09-06T14:30:08.251Z","contentChangedAt":"2026-09-06T14:30:08.251Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}