{"record":{"id":"7501918eb697ca58","repo":"EllanJiang/GameFramework","slug":"delta-length-is-invalid","errorCode":null,"errorMessage":"Delta length is invalid.","messagePattern":"Delta length is invalid\\.","errorType":"exception","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/Download/DownloadAgentHelperUpdateLengthEventArgs.cs","lineNumber":41,"sourceCode":"        /// <summary>\n        /// 获取下载的增量数据大小。\n        /// </summary>\n        public int DeltaLength\n        {\n            get;\n            private set;\n        }\n\n        /// <summary>\n        /// 创建下载代理辅助器更新数据大小事件。\n        /// </summary>\n        /// <param name=\"deltaLength\">下载的增量数据大小。</param>\n        /// <returns>创建的下载代理辅助器更新数据大小事件。</returns>\n        public static DownloadAgentHelperUpdateLengthEventArgs Create(int deltaLength)\n        {\n            if (deltaLength <= 0)\n            {\n                throw new GameFrameworkException(\"Delta length is invalid.\");\n            }\n\n            DownloadAgentHelperUpdateLengthEventArgs downloadAgentHelperUpdateLengthEventArgs = ReferencePool.Acquire<DownloadAgentHelperUpdateLengthEventArgs>();\n            downloadAgentHelperUpdateLengthEventArgs.DeltaLength = deltaLength;\n            return downloadAgentHelperUpdateLengthEventArgs;\n        }\n\n        /// <summary>\n        /// 清理下载代理辅助器更新数据大小事件。\n        /// </summary>\n        public override void Clear()\n        {\n            DeltaLength = 0;\n        }\n    }\n}\n","sourceCodeStart":23,"sourceCodeEnd":58,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/Download/DownloadAgentHelperUpdateLengthEventArgs.cs#L23-L58","documentation":"DownloadAgentHelperUpdateLengthEventArgs.Create requires a strictly positive delta length because it represents newly downloaded byte count used for progress and speed calculation. A zero or negative delta would corrupt the download statistics, so the library rejects it at creation time.","triggerScenarios":"Calling DownloadAgentHelperUpdateLengthEventArgs.Create with deltaLength <= 0, typically from a custom IDownloadAgentHelper reporting a download-progress event with a non-positive increment.","commonSituations":"Custom helper implementations calling the update-length callback on every poll tick even when no bytes arrived, or a signed underflow when computing the increment.","solutions":["Only fire the update-length event when the delta is > 0","Compute delta as currentLength - lastReportedLength and skip the call when it is 0","Check for integer underflow when subtracting length counters"],"exampleFix":"// before\nhelperCallback.UpdateLength(deltaLength); // deltaLength may be 0\n// after\nif (deltaLength > 0) helperCallback.UpdateLength(deltaLength);","handlingStrategy":"validation","validationCode":"if (deltaLength <= 0) return; // skip event when no new bytes arrived","typeGuard":"bool IsPositiveDelta(int deltaLength) => deltaLength > 0;","tryCatchPattern":"try { var args = DownloadAgentHelperUpdateLengthEventArgs.Create(deltaLength); } catch (GameFrameworkException ex) { Log.Warning(\"Invalid download delta length: {0}\", ex.Message); }","preventionTips":["Only fire progress events on actual byte movement","Watch for signed integer underflow in length math","Log deltas periodically to catch zero-increment spam early"],"tags":["download","argument-validation","progress","unity","gameframework"],"backgroundTag":"argument-out-of-range","analyzedSha":"d0c010b05167c58e92350449d04864a91ca13fd2","analyzedAt":"2026-09-15T13:37:15.352Z","contentChangedAt":"2026-09-15T13:37:15.352Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}