{"record":{"id":"5b185c6b3db2d974","repo":"elsa-workflows/elsa-core","slug":"a-stimulus-name-is-required","errorCode":null,"errorMessage":"A stimulus name is required.","messagePattern":"A stimulus name is required\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/modules/Elsa.Workflows.Core/Models/NamedTriggerPayload.cs","lineNumber":21,"sourceCode":"/// <summary>\n/// A trigger payload that carries its own stimulus name.\n/// </summary>\n/// <remarks>\n/// Return instances of this type from <see cref=\"ITrigger.GetTriggerPayloadsAsync\"/> when a single trigger needs to register payloads under\n/// more than one stimulus name. The wrapper is unwrapped during indexing: the stored trigger's name and hash are derived from <see cref=\"Name\"/>\n/// and its payload from <see cref=\"Payload\"/>. Payloads that are not wrapped are named using <see cref=\"TriggerIndexingContext.TriggerName\"/>.\n/// </remarks>\npublic record NamedTriggerPayload\n{\n    /// <summary>\n    /// Initializes a new instance of the <see cref=\"NamedTriggerPayload\"/> class.\n    /// </summary>\n    /// <param name=\"name\">The stimulus name to register the payload under.</param>\n    /// <param name=\"payload\">The payload to register.</param>\n    public NamedTriggerPayload(string name, object payload)\n    {\n        if (string.IsNullOrWhiteSpace(name))\n            throw new ArgumentException(\"A stimulus name is required.\", nameof(name));\n\n        if (payload is NamedTriggerPayload)\n            throw new ArgumentException(\"A NamedTriggerPayload cannot wrap another NamedTriggerPayload.\", nameof(payload));\n\n        Name = name;\n        Payload = payload;\n    }\n\n    /// <summary>\n    /// The stimulus name to register the payload under. Publishers of this stimulus compute their hash from this same name.\n    /// </summary>\n    public string Name { get; }\n\n    /// <summary>\n    /// The payload to register. This is what gets stored; the wrapper itself never is, since the constructor refuses to wrap another\n    /// <see cref=\"NamedTriggerPayload\"/>.\n    /// </summary>\n    public object Payload { get; }","sourceCodeStart":3,"sourceCodeEnd":39,"githubUrl":"https://github.com/elsa-workflows/elsa-core/blob/fe9217bdfa0e27f0e09e45006eb6898f616e513d/src/modules/Elsa.Workflows.Core/Models/NamedTriggerPayload.cs#L3-L39","documentation":"NamedTriggerPayload's constructor requires a non-empty, non-whitespace stimulus name and throws ArgumentException naming the parameter otherwise. The name is the key under which the payload is registered for trigger matching. This is an argument-validation guard, so the exception is thrown at construction time, not at workflow execution time.","triggerScenarios":"new NamedTriggerPayload(\"\", payload), new NamedTriggerPayload(\" \", payload), or passing a name sourced from a null/empty variable or config value.","commonSituations":"Building payloads dynamically from event names that came back empty; reading the name from deserialized config where a field was missing; passing a variable that was never initialized.","solutions":["Pass a meaningful non-empty stimulus name when constructing the payload","Validate/normalize the name before construction and fail with a clearer error","Ensure the config or variable that supplies the name is populated"],"exampleFix":"// before\nvar payload = new NamedTriggerPayload(eventName, data);\n// after\nif (string.IsNullOrWhiteSpace(eventName)) throw new InvalidOperationException(\"Event name must be configured.\");\nvar payload = new NamedTriggerPayload(eventName, data);","handlingStrategy":"validation","validationCode":"if (string.IsNullOrWhiteSpace(name)) throw new InvalidOperationException(\"Stimulus name is required.\");","typeGuard":null,"tryCatchPattern":"try { var p = new NamedTriggerPayload(name, payload); } catch (ArgumentException ex) when (ex.ParamName == \"name\") { /* surface config problem */ }","preventionTips":["Never construct payload names from unvalidated config or event data","Normalize/trim names at the boundary where they're produced"],"tags":["argument","validation","triggers"],"backgroundTag":"missing-required-argument","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"}