{"record":{"id":"6f272cc0fe81e4a0","repo":"apache/shardingsphere","slug":"s-execution-mode-is-required-6f272c","errorCode":null,"errorMessage":"%s execution_mode is required.","messagePattern":"(.+?) execution_mode is required\\.","errorType":"validation","errorClass":"MCPExecutionModeRequiredException","httpStatus":null,"severity":"error","filePath":"mcp/core/src/main/java/org/apache/shardingsphere/mcp/core/tool/handler/workflow/WorkflowExecutionToolHandler.java","lineNumber":65,"sourceCode":"    \n    private final WorkflowRuntimeDefinitionRegistry workflowRuntimeDefinitionRegistry;\n    \n    @Override\n    public Class<MCPFeatureRequestContext> getContextType() {\n        return MCPFeatureRequestContext.class;\n    }\n    \n    @Override\n    public String getToolName() {\n        return WorkflowToolDescriptors.APPLY_TOOL_NAME;\n    }\n    \n    @Override\n    public MCPSuccessPayload handle(final MCPFeatureRequestContext requestContext, final Map<String, Object> arguments) {\n        MCPToolArguments toolArguments = new MCPToolArguments(arguments);\n        String executionMode = toolArguments.getStringArgument(WorkflowFieldNames.EXECUTION_MODE);\n        if (executionMode.isEmpty()) {\n            throw new MCPExecutionModeRequiredException(WorkflowToolDescriptors.APPLY_TOOL_NAME, List.of(WorkflowLifecycle.EXECUTION_MODE_PREVIEW,\n                    WorkflowLifecycle.EXECUTION_MODE_REVIEW_THEN_EXECUTE, WorkflowLifecycle.EXECUTION_MODE_MANUAL_ONLY),\n                    createPreviewSuggestedArguments(arguments));\n        }\n        WorkflowSessionContext workflowSessionContext = requestContext.getWorkflowSessionContext();\n        WorkflowContextSnapshot snapshot = workflowSessionContext.getRequired(toolArguments.getStringArgument(WorkflowFieldNames.PLAN_ID));\n        WorkflowRuntimeDefinition workflowRuntimeDefinition = workflowRuntimeDefinitionRegistry.getRequired(snapshot);\n        return new MCPMapPayload(executionService.apply(workflowSessionContext, requestContext.getQueryFacade(), requestContext.getExecutionFacade(),\n                workflowRuntimeDefinition.getRuntimeHandler(), workflowRuntimeDefinition.getApplyArtifactValidator(),\n                requestContext.getSessionIdentity().getSessionId(),\n                snapshot, toolArguments.getStringCollectionArgument(WorkflowFieldNames.APPROVED_STEPS), executionMode));\n    }\n    \n    private static Map<String, Object> createPreviewSuggestedArguments(final Map<String, Object> arguments) {\n        Map<String, Object> result = new LinkedHashMap<>(arguments);\n        result.remove(WorkflowFieldNames.EXECUTION_MODE);\n        result.put(WorkflowFieldNames.EXECUTION_MODE, WorkflowLifecycle.EXECUTION_MODE_PREVIEW);\n        return result;\n    }","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/apache/shardingsphere/blob/e952770a215630a3659c75d64369168cd3e26b82/mcp/core/src/main/java/org/apache/shardingsphere/mcp/core/tool/handler/workflow/WorkflowExecutionToolHandler.java#L47-L83","documentation":"Thrown by WorkflowExecutionToolHandler.handle as MCPExecutionModeRequiredException when the workflow apply tool is called without an execution_mode argument (missing or empty string). Execution of workflow artifacts is safety-critical, so the tool refuses to guess; the exception advertises the accepted modes (preview, review_then_execute, manual_only) and a suggested preview argument set.","triggerScenarios":"toolArguments.getStringArgument(WorkflowFieldNames.EXECUTION_MODE) returns \"\" because the arguments map has no execution_mode key or an empty value. Any apply call like apply({\"plan_id\": \"p1\"}) without execution_mode triggers it.","commonSituations":"Agent clients omitting execution_mode and assuming a default; version upgrades that introduced the required field into an existing integration; UI forms that send the field only when non-empty.","solutions":["Add execution_mode to the apply call with one of the advertised values — start with preview for safety","Read the allowed values from the exception payload (it includes EXECUTION_MODE_PREVIEW/REVIEW_THEN_EXECUTE/MANUAL_ONLY and suggested arguments) instead of hard-coding assumptions","Make the field mandatory in your client schema/validation so the request never leaves without it"],"exampleFix":"// before\napply({\"plan_id\": \"p1\"})\n\n// after\napply({\"plan_id\": \"p1\", \"execution_mode\": \"preview\"})","handlingStrategy":"try-catch","validationCode":"if (!arguments.containsKey(\"execution_mode\") || String.valueOf(arguments.get(\"execution_mode\")).isBlank()) {\n    arguments.put(\"execution_mode\", \"preview\"); // safe default\n}","typeGuard":null,"tryCatchPattern":"try {\n    return applyTool.handle(ctx, arguments);\n} catch (MCPExecutionModeRequiredException e) {\n    // e carries allowed modes and a suggested preview argument set\n    arguments.put(\"execution_mode\", e.getSuggestedArguments().containsKey(\"execution_mode\")\n            ? e.getSuggestedArguments().get(\"execution_mode\") : \"preview\");\n    return applyTool.handle(ctx, arguments);\n}","preventionTips":["Always send an explicit execution_mode, defaulting to preview","Treat apply as unsafe-by-default: no mode, no execution"],"tags":["mcp","workflow","required-argument","execution-mode","shardingsphere"],"backgroundTag":null,"analyzedSha":"e952770a215630a3659c75d64369168cd3e26b82","analyzedAt":"2026-08-14T13:54:53.392Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}