{"record":{"id":"1b852c11d2dada4e","repo":"apache/shenyu","slug":"openapi-methodtype-cannot-be-null-or-empty","errorCode":null,"errorMessage":"OpenAPI methodType cannot be null or empty","messagePattern":"OpenAPI methodType cannot be null or empty","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"shenyu-client/shenyu-client-mcp/shenyu-client-mcp-register/src/main/java/org/apache/shenyu/client/mcp/McpServiceEventListener.java","lineNumber":383,"sourceCode":"                                                         final String url, final String namespaceId) {\n        validateClientConfig(shenyuMcpTool, url);\n        JsonObject openApiJson = McpOpenApiGenerator.generateOpenApiJson(classShenyuClient, shenyuMcpTool, url);\n        McpToolsRegisterDTO mcpToolsRegisterDTO = McpToolsRegisterDTOGenerator.generateRegisterDTO(shenyuMcpTool, openApiJson, url, namespaceId);\n        MetaDataRegisterDTO metaDataRegisterDTO = buildMetaDataDTO(bean, classShenyuClient, url, clazz, method, namespaceId);\n        metaDataRegisterDTO.setEnabled(shenyuMcpTool.getEnable());\n        mcpToolsRegisterDTO.setMetaDataRegisterDTO(metaDataRegisterDTO);\n        return mcpToolsRegisterDTO;\n    }\n\n    private void validateClientConfig(final org.apache.shenyu.client.mcp.common.dto.ShenyuMcpTool methodShenyuClient, final String url) {\n        if (StringUtils.isBlank(url)) {\n            log.error(\"OpenAPI pathKey is null or empty, please check OpenApiConfig\");\n            throw new IllegalArgumentException(\"OpenAPI pathKey cannot be null or empty\");\n        }\n\n        if (StringUtils.isBlank(methodShenyuClient.getMethod())) {\n            log.error(\"OpenAPI methodType is null or empty, please check OpenApiConfig\");\n            throw new IllegalArgumentException(\"OpenAPI methodType cannot be null or empty\");\n        }\n    }\n\n}\n","sourceCodeStart":365,"sourceCodeEnd":388,"githubUrl":"https://github.com/apache/shenyu/blob/567142e07261b3e615ae8850b30f4421f455cc5d/shenyu-client/shenyu-client-mcp/shenyu-client-mcp-register/src/main/java/org/apache/shenyu/client/mcp/McpServiceEventListener.java#L365-L388","documentation":"McpServiceEventListener.validateClientConfig also requires the ShenyuMcpTool's method (HTTP methodType, e.g. GET/POST) to be non-blank. When blank it logs a hint about OpenApiConfig and throws IllegalArgumentException, preventing registration of a tool with no HTTP method.","triggerScenarios":"Building MCP tools register DTOs when the @ShenyuMcpTool's OpenApiConfig methodType is null or empty while pathKey is valid.","commonSituations":"Tool configs hand-written without methodType; spec conversion dropping the http method; annotation attributes left at defaults that resolve to empty.","solutions":["Set methodType (GET/POST/etc.) on the OpenApiConfig of each @ShenyuMcpTool","Validate tool DTOs before registration to catch blanks early","Check logs for 'OpenAPI methodType is null or empty' to find the offending tool","Regenerate tool definitions from the OpenAPI spec preserving operation methods"],"exampleFix":"// before\n@OpenApiConfig(pathKey = \"/weather\")\n// after\n@OpenApiConfig(pathKey = \"/weather\", methodType = \"GET\")","handlingStrategy":"validation","validationCode":"if (tool.getOpenApiConfig() == null || StringUtils.isBlank(tool.getOpenApiConfig().getMethodType())) {\n    throw new IllegalStateException(\"@ShenyuMcpTool \" + tool.getName() + \" missing OpenApiConfig methodType\");\n}","typeGuard":null,"tryCatchPattern":"try { listener.buildMcpToolsRegisterDTO(tool); }\ncatch (IllegalArgumentException e) {\n    log.error(\"MCP tool config invalid: {}\", e.getMessage());\n}","preventionTips":["Always set methodType on OpenApiConfig","Validate tool definitions against the OpenAPI spec before registration","Keep generated tool configs in sync with spec operation methods"],"tags":["mcp","openapi","configuration","validation"],"backgroundTag":"missing-required-config-field","analyzedSha":"567142e07261b3e615ae8850b30f4421f455cc5d","analyzedAt":"2026-09-12T10:08:21.293Z","contentChangedAt":"2026-09-12T10:08:21.293Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}