{"record":{"id":"3529c24edba465a8","repo":"elsa-workflows/elsa-core","slug":"user-task-protected-payload-exceeds-the-configured-limit","errorCode":null,"errorMessage":"User Task protected payload exceeds the configured limit.","messagePattern":"User Task protected payload exceeds the configured limit\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/modules/Elsa.UserTasks/Services/DefaultUserTaskManager.cs","lineNumber":31,"sourceCode":"    IUserTaskRepository repository,\n    IUserTaskAccessPolicy accessPolicy,\n    IEnumerable<IUserTaskFormProvider> formProviders,\n    IUserTaskWorkflowResumer workflowResumer,\n    IUserTaskNotificationSink notificationSink,\n    IIdentityGenerator identityGenerator,\n    ISystemClock clock,\n    Microsoft.Extensions.Options.IOptions<UserTasksOptions> options,\n    IUserTaskParticipantDirectory? participantDirectory = null) : IUserTaskManager\n{\n    private readonly IReadOnlyDictionary<string, IUserTaskFormProvider> _formProviders = formProviders\n        .ToDictionary(x => x.Name, StringComparer.OrdinalIgnoreCase);\n    private readonly UserTasksOptions _options = options.Value;\n\n    public async Task<UserTaskProjectionResult> ProjectAsync(UserTaskMaterialization materialization, CancellationToken cancellationToken = default)\n    {\n        var definition = materialization.Definition.Normalize();\n        if (PayloadBytes(definition.TaskData) > _options.MaximumPayloadBytes || Encoding.UTF8.GetByteCount(definition.Instructions ?? \"\") > _options.MaximumPayloadBytes)\n            throw new ArgumentException(\"User Task protected payload exceeds the configured limit.\");\n        var existing = await repository.FindByMaterializationKeyAsync(materialization.TenantId, MaterializationKey(materialization), cancellationToken);\n        if (existing != null)\n            return new UserTaskProjectionResult(existing, false);\n\n        ResolvedUserTaskForm? pinnedForm = null;\n        var healthSeverity = (UserTaskHealthSeverity?)null;\n        string? healthCode = null;\n        string? healthMessage = null;\n        var snapshotMembers = materialization.SnapshotMembers.ToList();\n        var snapshotGroups = materialization.SnapshotGroups.ToList();\n        if (definition.MembershipResolutionMode == UserTaskMembershipResolutionMode.Snapshot)\n        {\n            snapshotMembers.AddRange(definition.CandidateUsers);\n            snapshotGroups.AddRange(definition.CandidateGroups);\n            if (participantDirectory != null)\n            {\n                foreach (var group in definition.CandidateGroups)\n                {","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/elsa-workflows/elsa-core/blob/fe9217bdfa0e27f0e09e45006eb6898f616e513d/src/modules/Elsa.UserTasks/Services/DefaultUserTaskManager.cs#L13-L49","documentation":"DefaultUserTaskManager.ProjectAsync checks the materialized task's protected payload size before persisting: both the serialized TaskData and the UTF-8 byte length of Instructions must fit within UserTasksOptions.MaximumPayloadBytes. If either exceeds the limit, an ArgumentException is thrown and the task is not created. This protects the store and downstream consumers from oversized payloads.","triggerScenarios":"Materializing a User Task whose TaskData JSON exceeds the configured byte limit, or whose Instructions string is longer than the limit in bytes (multi-byte characters count more than characters); calling ProjectAsync with a large form payload or very long instructions.","commonSituations":"Users pasting long text into task instructions; passing large documents/arrays as task data instead of a reference; MaximumPayloadBytes lowered via options (e.g. from a default to a stricter value) so previously valid payloads now fail.","solutions":["Reduce the payload: trim TaskData to only what the task form needs and shorten instructions.","Increase UserTasksOptions.MaximumPayloadBytes in configuration if the limit is genuinely too small for your use case.","Store large blobs externally (file/object storage) and pass a reference/URL in TaskData instead."],"exampleFix":"// before\nservices.Configure<UserTasksOptions>(o => o.MaximumPayloadBytes = 8 * 1024);\n// after\nservices.Configure<UserTasksOptions>(o => o.MaximumPayloadBytes = 64 * 1024);","handlingStrategy":"validation","validationCode":"var bytes = Encoding.UTF8.GetByteCount(JsonSerializer.Serialize(materialization.Definition.TaskData ?? new object()));\nif (bytes > options.MaximumPayloadBytes) throw new InvalidOperationException(\"Task data exceeds payload limit.\");","typeGuard":null,"tryCatchPattern":"try { await manager.ProjectAsync(materialization, ct); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"payload exceeds\")) { /* shrink payload and retry */ }","preventionTips":["Check payload sizes before projecting tasks with large inputs","Keep instructions concise; link to documentation instead of embedding it","Set an explicit MaximumPayloadBytes aligned with your storage constraints"],"tags":["user-task","payload-size","validation"],"backgroundTag":"payload-too-large","analyzedSha":"fe9217bdfa0e27f0e09e45006eb6898f616e513d","analyzedAt":"2026-09-13T20:32:34.702Z","contentChangedAt":"2026-09-13T20:32:34.702Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}