{"record":{"id":"df4ca53c9e3de53f","repo":"apache/shenyu","slug":"request-configuration-cannot-be-empty","errorCode":null,"errorMessage":"Request configuration cannot be empty","messagePattern":"Request configuration cannot be empty","errorType":"validation","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"shenyu-plugin/shenyu-plugin-mcp-server/src/main/java/org/apache/shenyu/plugin/mcp/server/callback/ShenyuToolCallback.java","lineNumber":188,"sourceCode":"    private ShenyuToolDefinition validateToolDefinition() {\n        if (!(this.toolDefinition instanceof ShenyuToolDefinition)) {\n            throw new IllegalStateException(\"Tool definition must be of type ShenyuToolDefinition, got: \"\n                    + this.toolDefinition.getClass().getSimpleName());\n        }\n        return (ShenyuToolDefinition) this.toolDefinition;\n    }\n\n    /**\n     * Extracts and validates the request configuration from the tool definition.\n     *\n     * @param definition the Shenyu tool definition\n     * @return the request configuration string\n     * @throws IllegalStateException if configuration is missing or invalid\n     */\n    private String extractRequestConfig(final ShenyuToolDefinition definition) {\n        final String config = definition.requestConfig();\n        if (!StringUtils.hasText(config)) {\n            throw new IllegalStateException(\"Request configuration cannot be empty\");\n        }\n        LOG.debug(\"Using request configuration with length: {} chars\", config.length());\n        return config;\n    }\n\n    /**\n     * Extracts the plugin chain from the exchange.\n     *\n     * @param exchange the server web exchange\n     * @return the plugin chain\n     * @throws IllegalStateException if chain is not found\n     */\n    private ShenyuPluginChain getPluginChain(final ServerWebExchange exchange) {\n        final ShenyuPluginChain chain = exchange.getAttribute(Constants.CHAIN);\n        Assert.notNull(chain, \"ShenyuPluginChain cannot be null\");\n        return chain;\n    }\n","sourceCodeStart":170,"sourceCodeEnd":206,"githubUrl":"https://github.com/apache/shenyu/blob/567142e07261b3e615ae8850b30f4421f455cc5d/shenyu-plugin/shenyu-plugin-mcp-server/src/main/java/org/apache/shenyu/plugin/mcp/server/callback/ShenyuToolCallback.java#L170-L206","documentation":"extractRequestConfig reads the requestConfig string from the ShenyuToolDefinition and throws IllegalStateException when it is null or blank. The ShenYu MCP bridge needs this config (target path, method, etc.) to translate a tool call into an HTTP request, so an empty config makes the tool unusable.","triggerScenarios":"A tool definition was registered with requestConfig missing, empty, or whitespace-only — e.g. ShenyuToolDefinition built without requestConfig, or admin-side MCP tool config where the request config field was left blank.","commonSituations":"Hand-crafting tool specs in code and omitting requestConfig; creating an MCP tool in the ShenYu admin dashboard without filling the request configuration JSON; sync lag leaving a partially populated tool definition.","solutions":["Provide a non-empty requestConfig when building the ShenyuToolDefinition (JSON describing method/path of the downstream call).","In the admin dashboard, fill in the tool's request configuration and re-publish.","Print/inspect definition.requestConfig() during registration to catch blanks early."],"exampleFix":"// before\nShenyuToolDefinition.builder().name(\"get-user\").build();\n// after\nShenyuToolDefinition.builder().name(\"get-user\").requestConfig(\"{\\\"request\\\":{\\\"method\\\":\\\"GET\\\",\\\"path\\\":\\\"/user\\\"}}\").build();","handlingStrategy":"validation","validationCode":"if (def instanceof ShenyuToolDefinition s\n        && !StringUtils.hasText(s.requestConfig())) {\n    throw new IllegalArgumentException(\"Tool '\" + s.name() + \"' has empty requestConfig\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    return callback.call(args, ctx);\n} catch (IllegalStateException e) {\n    if (\"Request configuration cannot be empty\".equals(e.getMessage())) {\n        return \"Tool is misconfigured: request configuration missing\";\n    }\n    throw e;\n}","preventionTips":["Make requestConfig a required field in your tool-registration helper.","Validate tool config in CI: load all tool definitions and assert requestConfig has text.","In the admin dashboard, mark request configuration as mandatory before publishing.","Fail fast at registration with a clear per-tool error instead of at call time."],"tags":["mcp","configuration","empty-value","ai"],"backgroundTag":"empty-required-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"}