{"record":{"id":"c20af2e13d434cce","repo":"apache/shardingsphere","slug":"s-execution-mode-is-required-c20af2","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/workflow/WorkflowExecutionService.java","lineNumber":107,"sourceCode":"        }\n        Map<String, Object> invalidArtifactResponse = validateApplyArtifacts(workflowSessionContext, snapshot, actualExecutionMode, workflowApplyArtifactValidator);\n        if (!invalidArtifactResponse.isEmpty()) {\n            return invalidArtifactResponse;\n        }\n        WorkflowApplyOutcome applyOutcome = new WorkflowApplyOutcome();\n        if (WorkflowLifecycle.EXECUTION_MODE_PREVIEW.equalsIgnoreCase(actualExecutionMode)) {\n            return previewApply(workflowSessionContext, snapshot);\n        }\n        if (isManualOnly(actualExecutionMode)) {\n            return applyManualOnly(workflowSessionContext, snapshot, applyOutcome);\n        }\n        return applyAutomatically(workflowSessionContext, queryFacade, executionFacade, workflowRuntimeHandler, sessionId, snapshot,\n                actualExecutionMode, applyOutcome);\n    }\n    \n    private String requireExecutionMode(final WorkflowContextSnapshot snapshot, final String executionMode) {\n        if (executionMode.isEmpty()) {\n            throw new MCPExecutionModeRequiredException(WorkflowToolDescriptors.APPLY_TOOL_NAME, EXECUTION_MODES, createPreviewSuggestedArguments(snapshot));\n        }\n        String result = executionMode.toLowerCase(Locale.ENGLISH);\n        if (!EXECUTION_MODES.contains(result)) {\n            throw new MCPInvalidExecutionModeException(WorkflowToolDescriptors.APPLY_TOOL_NAME, EXECUTION_MODES, createPreviewSuggestedArguments(snapshot));\n        }\n        return result;\n    }\n    \n    private void requireApprovedSteps(final WorkflowContextSnapshot snapshot, final List<String> approvedSteps) {\n        if (null == approvedSteps || approvedSteps.isEmpty()) {\n            return;\n        }\n        for (String each : approvedSteps) {\n            if (!ALLOWED_APPROVAL_STEPS.contains(each)) {\n                throw new MCPInvalidApprovedStepsException(ALLOWED_APPROVAL_STEPS, createPreviewSuggestedArguments(snapshot));\n            }\n        }\n    }","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/apache/shardingsphere/blob/e952770a215630a3659c75d64369168cd3e26b82/mcp/core/src/main/java/org/apache/shardingsphere/mcp/core/workflow/WorkflowExecutionService.java#L89-L125","documentation":"Thrown by WorkflowExecutionService.requireExecutionMode when the apply tool is invoked with an empty execution_mode string. The workflow apply operation is ambiguous without an explicit mode (e.g. preview vs. apply), so the service rejects the request with MCPExecutionModeRequiredException and includes suggested arguments for a preview run.","triggerScenarios":"Invoking the workflow apply tool with execution_mode set to \"\" (present but empty) or an empty-valued field. A missing/null field that resolves to an empty string in the request mapping also triggers it.","commonSituations":"An LLM agent builds the apply request from a template and fills execution_mode with an empty string; a client forwards a form field that was never populated; confusion between the plan tool (which needs no mode) and the apply tool (which requires one).","solutions":["Supply execution_mode with an allowed value (e.g. \"preview\" before any real apply) — the accepted set is returned in the exception and matches WorkflowLifecycle.EXECUTION_MODES.","Use the suggestedArguments payload from MCPExecutionModeRequiredException to retry with a valid preview request.","If your client omits optional fields, make sure execution_mode is not being serialized as \"\" instead of being absent."],"exampleFix":"// before\narguments.put(\"execution_mode\", \"\");\n// after\narguments.put(\"execution_mode\", \"preview\");","handlingStrategy":"validation","validationCode":"if (null == executionMode || executionMode.trim().isEmpty()) {\n    executionMode = \"preview\"; // or refuse to call apply until the user picks a mode\n}","typeGuard":"const hasExecutionMode = m => typeof m?.execution_mode === \"string\" && m.execution_mode.trim().length > 0;","tryCatchPattern":"try {\n    applyResult = applyTool.call(request);\n} catch (final MCPExecutionModeRequiredException ex) {\n    // ex carries EXECUTION_MODES and preview suggestedArguments; retry with them\n}","preventionTips":["Always default to preview before apply in agent workflows","Serialize absent optional strings by omitting the key, never as \"\"","Read the required-mode list from the tool descriptor each session"],"tags":["mcp","workflow","validation","execution-mode"],"backgroundTag":null,"analyzedSha":"e952770a215630a3659c75d64369168cd3e26b82","analyzedAt":"2026-08-14T13:54:53.392Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}