{"record":{"id":"f92945f1ea8d4abc","repo":"apache/shardingsphere","slug":"s-execution-mode-must-be-one-of-s-f92945","errorCode":null,"errorMessage":"%s execution_mode must be one of %s.","messagePattern":"(.+?) execution_mode must be one of (.+?)\\.","errorType":"validation","errorClass":"MCPInvalidExecutionModeException","httpStatus":null,"severity":"error","filePath":"mcp/core/src/main/java/org/apache/shardingsphere/mcp/core/workflow/WorkflowExecutionService.java","lineNumber":111,"sourceCode":"        }\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    }\n    \n    private Map<String, Object> checkApplyPreconditions(final String sessionId, final WorkflowContextSnapshot snapshot, final String executionMode,\n                                                        final List<String> approvedSteps) {\n        if (!WorkflowLifecycleUtils.isOwnedBySession(sessionId, snapshot)) {","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/apache/shardingsphere/blob/e952770a215630a3659c75d64369168cd3e26b82/mcp/core/src/main/java/org/apache/shardingsphere/mcp/core/workflow/WorkflowExecutionService.java#L93-L129","documentation":"Thrown by WorkflowExecutionService.requireExecutionMode when execution_mode is non-empty but, after lowercasing, is not one of the supported WorkflowLifecycle.EXECUTION_MODES values. The request is rejected with MCPInvalidExecutionModeException, which carries the tool name, the full allowed-mode list, and preview-suggested arguments.","triggerScenarios":"Calling the workflow apply tool with an execution_mode such as \"execute\", \"dry-run\", \"auto\", or a misspelling of an allowed value; matching is case-insensitive but exact-string after lowercasing, so plurals or synonyms fail.","commonSituations":"Agents guessing mode names (\"dry_run\" instead of \"preview\"), documentation drift between client SDK and server versions where the mode vocabulary changed, or copy-paste from a different tool's API.","solutions":["Read the allowed modes from the MCPInvalidExecutionModeException payload (or WorkflowLifecycle.EXECUTION_MODES) and retry with one of them exactly, e.g. \"preview\".","Start with \"preview\" mode when unsure — the exception's suggestedArguments already encode a valid preview request.","Pin the client and server to compatible versions so the mode vocabulary matches."],"exampleFix":"// before\narguments.put(\"execution_mode\", \"dry-run\");\n// after\narguments.put(\"execution_mode\", \"preview\");","handlingStrategy":"validation","validationCode":"Set<String> allowed = WorkflowLifecycle.EXECUTION_MODES;\nString candidate = executionMode == null ? \"\" : executionMode.toLowerCase(Locale.ENGLISH);\nif (!allowed.contains(candidate)) { throw new IllegalArgumentException(\"use one of \" + allowed); }","typeGuard":"const isExecutionMode = m => EXECUTION_MODES.includes((m?.execution_mode ?? \"\").toLowerCase());","tryCatchPattern":"try {\n    applyTool.call(request);\n} catch (final MCPInvalidExecutionModeException ex) {\n    // message lists valid modes; retry with one of them (\"preview\" is always a safe start)\n}","preventionTips":["Copy mode names verbatim from the exception payload, do not paraphrase","Treat mode vocabulary as version-dependent and re-read it after upgrades","Prefer preview mode whenever the intent is uncertain"],"tags":["mcp","workflow","validation","execution-mode"],"backgroundTag":null,"analyzedSha":"e952770a215630a3659c75d64369168cd3e26b82","analyzedAt":"2026-08-14T13:54:53.392Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}