{"record":{"id":"d4de31313124acb7","repo":"elsa-workflows/elsa-core","slug":"elsa-platform-artifact-exceeds-the-configured-runtime-size","errorCode":null,"errorMessage":"Elsa Platform artifact exceeds the configured runtime size limit.","messagePattern":"Elsa Platform artifact exceeds the configured runtime size limit\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/modules/Elsa.Platform.Integration/Services/PlatformRuntimeCommandClient.cs","lineNumber":137,"sourceCode":"        var relative = path.StartsWith(\"/api/\", StringComparison.OrdinalIgnoreCase)\n            ? path\n            : $\"/api/workspaces/{_options.WorkspaceId:D}{path}\";\n        return new Uri($\"{endpoint.AbsoluteUri.TrimEnd('/')}{relative}\");\n    }\n\n    private async Task CopyBoundedAsync(Stream source, Stream destination, CancellationToken cancellationToken)\n    {\n        var buffer = new byte[81920];\n        long total = 0;\n        while (true)\n        {\n            var read = await source.ReadAsync(buffer, cancellationToken);\n            if (read == 0)\n                return;\n\n            total += read;\n            if (total > _options.MaxArtifactBytes)\n                throw new InvalidOperationException(\"Elsa Platform artifact exceeds the configured runtime size limit.\");\n\n            await destination.WriteAsync(buffer.AsMemory(0, read), cancellationToken);\n        }\n    }\n\n    private static JsonSerializerOptions CreateJsonOptions()\n    {\n        var options = new JsonSerializerOptions(JsonSerializerDefaults.Web);\n        options.Converters.Add(new JsonStringEnumConverter(allowIntegerValues: false));\n        return options;\n    }\n}\n","sourceCodeStart":119,"sourceCodeEnd":150,"githubUrl":"https://github.com/elsa-workflows/elsa-core/blob/fe9217bdfa0e27f0e09e45006eb6898f616e513d/src/modules/Elsa.Platform.Integration/Services/PlatformRuntimeCommandClient.cs#L119-L150","documentation":"DownloadArtifactAsync streams an artifact from the Elsa Platform runtime to a destination while enforcing a configured maximum size (_options.MaxArtifactBytes). As soon as the cumulative byte count exceeds that limit, the copy loop aborts and this InvalidOperationException is thrown, protecting the host from unbounded downloads exhausting memory or disk.","triggerScenarios":"Calling DownloadArtifactAsync for an artifact whose total size is larger than MaxArtifactBytes configured in the platform runtime client options; the exception is raised mid-stream after the first chunk pushes total past the limit.","commonSituations":"Deploying a large recipe/artifact bundle (large workflow export, big embedded files) while the client was configured with a small or default MaxArtifactBytes; limits tightened for security without updating environments that ship big artifacts.","solutions":["Increase MaxArtifactBytes in the platform runtime client options to a value larger than the expected artifact size.","Verify the artifact on the server: check it does not accidentally contain large binaries or duplicated payloads that inflate its size.","If the artifact is legitimately huge, split it into smaller artifacts or stream it through a mechanism not bounded by this client limit.","Add pre-flight size checking (artifact metadata/content-length) so users get a clear error before streaming starts."],"exampleFix":"// before\noptions.MaxArtifactBytes = 1 * 1024 * 1024; // 1 MB\n// after\noptions.MaxArtifactBytes = 64 * 1024 * 1024; // 64 MB, room for real artifacts","handlingStrategy":"validation","validationCode":"var size = await GetArtifactSizeAsync(artifactId); // e.g. content-length / metadata\nif (size > options.MaxArtifactBytes)\n    throw new InvalidOperationException($\"Artifact is {size} bytes, exceeding limit {options.MaxArtifactBytes}.\");","typeGuard":null,"tryCatchPattern":"try\n{\n    await client.DownloadArtifactAsync(artifactId, destination, ct);\n}\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"exceeds the configured runtime size limit\"))\n{\n    logger.LogWarning(ex, \"Artifact download rejected: size limit exceeded.\");\n}","preventionTips":["Set MaxArtifactBytes above your largest legitimate artifact, per environment.","Check artifact metadata/content-length before streaming.","Monitor artifact sizes in CI so growth beyond limits is caught early."],"tags":["io","size-limit","streaming","configuration"],"backgroundTag":"file-size-limit-exceeded","analyzedSha":"fe9217bdfa0e27f0e09e45006eb6898f616e513d","analyzedAt":"2026-09-13T20:32:34.702Z","contentChangedAt":"2026-09-13T20:32:34.702Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}