{"record":{"id":"7a33043bb0a164ea","repo":"elsa-workflows/elsa-core","slug":"elsa-platform-engine-id-is-required-when-platform","errorCode":null,"errorMessage":"Elsa Platform engine ID is required when Platform integration is enabled.","messagePattern":"Elsa Platform engine ID is required when Platform integration is enabled\\.","errorType":"validation","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/modules/Elsa.Platform.Integration/Options/ElsaPlatformIntegrationOptions.cs","lineNumber":39,"sourceCode":"    public TimeSpan ClaimLeaseDuration { get; set; } = TimeSpan.FromMinutes(5);\n\n    public long MaxArtifactBytes { get; set; } = 4 * 1024 * 1024;\n\n    public string ShellOverlayPath { get; set; } = \"platform-shell-overrides.json\";\n\n    public IReadOnlyList<string> Capabilities { get; set; } = [\"loom.recipe.apply\"];\n\n    public void Validate()\n    {\n        if (!Enabled)\n            return;\n\n        if (PlatformEndpoint is null)\n            throw new InvalidOperationException(\"Elsa Platform endpoint is required when Platform integration is enabled.\");\n        if (WorkspaceId == Guid.Empty)\n            throw new InvalidOperationException(\"Elsa Platform workspace ID is required when Platform integration is enabled.\");\n        if (EngineId == Guid.Empty)\n            throw new InvalidOperationException(\"Elsa Platform engine ID is required when Platform integration is enabled.\");\n        if (string.IsNullOrWhiteSpace(EngineSecret))\n            throw new InvalidOperationException(\"Elsa Platform engine secret is required when Platform integration is enabled.\");\n        if (string.IsNullOrWhiteSpace(WorkerId))\n            throw new InvalidOperationException(\"Elsa Platform worker ID is required when Platform integration is enabled.\");\n        if (PollInterval <= TimeSpan.Zero)\n            throw new InvalidOperationException(\"Elsa Platform poll interval must be positive.\");\n        if (ClaimLeaseDuration < TimeSpan.FromSeconds(1) || ClaimLeaseDuration.TotalSeconds > int.MaxValue)\n            throw new InvalidOperationException(\"Elsa Platform claim lease duration must be between 1 second and the maximum supported Platform lease.\");\n        if (MaxArtifactBytes <= 0 || MaxArtifactBytes > Array.MaxLength)\n            throw new InvalidOperationException(\"Elsa Platform maximum artifact size must be between 1 byte and the maximum runtime buffer size.\");\n        if (string.IsNullOrWhiteSpace(ShellOverlayPath))\n            throw new InvalidOperationException(\"Elsa Platform shell overlay path is required when Platform integration is enabled.\");\n    }\n}\n","sourceCodeStart":21,"sourceCodeEnd":54,"githubUrl":"https://github.com/elsa-workflows/elsa-core/blob/fe9217bdfa0e27f0e09e45006eb6898f616e513d/src/modules/Elsa.Platform.Integration/Options/ElsaPlatformIntegrationOptions.cs#L21-L54","documentation":"Validate also requires a non-empty EngineId when the Platform integration is enabled. The engine ID uniquely identifies this engine instance to the Platform; Guid.Empty means it was never assigned and validation throws.","triggerScenarios":"Calling Validate() with Enabled=true and EngineId still Guid.Empty because it was not provided in configuration or code.","commonSituations":"Omitted Engine:Id in appsettings; template config copied without filling engine identity; registering a second engine without assigning it a distinct ID.","solutions":["Set options.EngineId to the engine's assigned Guid before validation.","Bind PlatformIntegration:EngineId from configuration and confirm non-empty at startup.","Generate a stable Guid per engine instance if the Platform does not pre-assign one."],"exampleFix":"// before\nvar options = new ElsaPlatformIntegrationOptions { Enabled = true, PlatformEndpoint = endpoint, WorkspaceId = wsId, EngineSecret = \"s\", WorkerId = \"w\" };\noptions.Validate();\n// after\nvar options = new ElsaPlatformIntegrationOptions { Enabled = true, PlatformEndpoint = endpoint, WorkspaceId = wsId, EngineId = Guid.Parse(\"...\"), EngineSecret = \"s\", WorkerId = \"w\" };\noptions.Validate();","handlingStrategy":"validation","validationCode":"if (options.Enabled && options.EngineId == Guid.Empty)\n    throw new InvalidOperationException(\"EngineId must be set when Platform integration is enabled.\");","typeGuard":"bool IsValid(ElsaPlatformIntegrationOptions o) => !o.Enabled || o.EngineId != Guid.Empty;","tryCatchPattern":"try { options.Validate(); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"engine ID is required\")) { /* fix config before engine registration */ }","preventionTips":["Assign each engine a stable Guid in configuration management.","Run Validate() in a startup health check.","Keep engine identity values in secret/config storage, not code defaults."],"tags":["configuration","options-validation","platform-integration","guid"],"backgroundTag":"missing-required-config-field","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"}