{"record":{"id":"c5227d1c4bf3f086","repo":"microsoft/semantic-kernel","slug":"default-handlers-must-not-have-an-eval-expressio","errorCode":null,"errorMessage":"`Default` handlers must not have an eval expression.","messagePattern":"`Default` handlers must not have an eval expression\\.","errorType":"exception","errorClass":"KernelException","httpStatus":null,"severity":"error","filePath":"dotnet/src/Experimental/Process.Core/ProcessAgentBuilder.cs","lineNumber":288,"sourceCode":"        if (conditions is not null)\n        {\n            foreach (var condition in conditions)\n            {\n                if (condition is null)\n                {\n                    continue;\n                }\n\n                if (condition.Type == DeclarativeProcessConditionType.Default)\n                {\n                    if (this.DefaultHandler is not null)\n                    {\n                        throw new KernelException(\"Only one `Default` handler is allowed in a group of event handlers.\");\n                    }\n\n                    if (!string.IsNullOrWhiteSpace(condition.Expression))\n                    {\n                        throw new KernelException(\"`Default` handlers must not have an eval expression.\");\n                    }\n\n                    this.DefaultHandler = new DeclarativeEventHandlerBuilder(condition);\n                }\n                else if (condition.Type == DeclarativeProcessConditionType.Eval)\n                {\n                    this.EvalHandlers ??= [];\n                    this.EvalHandlers.Add(new DeclarativeEventHandlerBuilder(condition));\n                }\n                else if (condition.Type == DeclarativeProcessConditionType.Always)\n                {\n                    if (this.DefaultHandler is not null)\n                    {\n                        throw new KernelException(\"Only one `Always` handler is allowed in a group of event handlers.\");\n                    }\n\n                    if (!string.IsNullOrWhiteSpace(condition.Expression))\n                    {","sourceCodeStart":270,"sourceCodeEnd":306,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/dotnet/src/Experimental/Process.Core/ProcessAgentBuilder.cs#L270-L306","documentation":"Thrown by DeclarativeEventHandlerGroupBuilder constructor when a condition of type Default has a non-whitespace Expression property. Default conditions are unconditional fallbacks — supplying an eval expression to a Default handler is contradictory by design.","triggerScenarios":"Creating a DeclarativeProcessCondition with Type == Default and a non-empty Expression string, then passing it to OnComplete or OnError. This can happen when authoring declarative YAML with a 'default' handler that also has an 'expression' field.","commonSituations":"Authoring declarative agent handler YAML/JSON where a 'default' case erroneously includes an eval expression. Copying an Eval handler definition and changing only the type to Default without clearing the expression. Deserialization of malformed condition data.","solutions":["Remove the Expression property from any condition with Type == Default.","If the expression is meaningful, change the condition Type to Eval instead of Default.","Validate that Default conditions have null or whitespace Expression before building the handler group."],"exampleFix":"// before\nvar condition = new DeclarativeProcessCondition\n{\n    Type = DeclarativeProcessConditionType.Default,\n    Expression = \"$.status == 'ok'\" // not allowed — throws\n};\n\n// after\nvar condition = new DeclarativeProcessCondition\n{\n    Type = DeclarativeProcessConditionType.Default // no expression\n};","handlingStrategy":"validation","validationCode":"public static void ValidateDefaultCondition(DeclarativeProcessCondition condition)\n{\n    if (condition.Type == DeclarativeProcessConditionType.Default\n        && !string.IsNullOrWhiteSpace(condition.Expression))\n    {\n        throw new KernelException(\"Default conditions must not have an eval expression.\");\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never set Expression on Default-type conditions.","If an expression is needed, use Eval type instead.","Validate declarative YAML to ensure 'default' handlers have no 'expression' field."],"tags":["semantic-kernel","process-framework","declarative","event-handlers","validation"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}