{"record":{"id":"d3898e88091f1ce3","repo":"apache/shenyu","slug":"is-malformed-shenyuclientsregistrar","errorCode":null,"errorMessage":" is malformed","messagePattern":" is malformed","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"shenyu-sdk/shenyu-sdk-spring/src/main/java/org/apache/shenyu/sdk/spring/ShenyuClientsRegistrar.java","lineNumber":370,"sourceCode":"    /**\n     * Gets url.\n     *\n     * @param url the url\n     * @return the url\n     */\n    static String getUrl(final String url) {\n        String resultUrl = url;\n        if (StringUtils.isNotBlank(resultUrl) && !(resultUrl.startsWith(\"#{\") && resultUrl.contains(\"}\"))) {\n            if (!resultUrl.contains(\"://\")) {\n                resultUrl = \"http://\" + resultUrl;\n            }\n            if (resultUrl.endsWith(\"/\")) {\n                resultUrl = resultUrl.substring(0, resultUrl.length() - 1);\n            }\n            try {\n                new URL(resultUrl);\n            } catch (MalformedURLException e) {\n                throw new IllegalArgumentException(resultUrl + \" is malformed\", e);\n            }\n        }\n        return resultUrl;\n    }\n\n    private String getUrl(final ConfigurableBeanFactory beanFactory, final Map<String, Object> attributes) {\n        String url = resolve(beanFactory, (String) attributes.get(\"url\"));\n        if (StringUtils.isBlank(url)) {\n            return getUrl(getName(beanFactory, attributes));\n        }\n        return getUrl(url);\n    }\n\n    private String getPath(final ConfigurableBeanFactory beanFactory, final Map<String, Object> attributes) {\n        String path = resolve(beanFactory, (String) attributes.get(\"path\"));\n        return getPath(path);\n    }\n","sourceCodeStart":352,"sourceCodeEnd":388,"githubUrl":"https://github.com/apache/shenyu/blob/567142e07261b3e615ae8850b30f4421f455cc5d/shenyu-sdk/shenyu-sdk-spring/src/main/java/org/apache/shenyu/sdk/spring/ShenyuClientsRegistrar.java#L352-L388","documentation":"Identical validation to the feign SDK: the spring SDK's ShenyuClientsRegistrar.getUrl() resolves the @ShenyuClient url attribute, strips a trailing slash, and validates it with java.net.URL. A string the URL constructor cannot parse causes IllegalArgumentException(\"<url> is malformed\") with the MalformedURLException as cause, failing at bean registration time.","triggerScenarios":"A spring-module @ShenyuClient whose url attribute resolves (after placeholder substitution) to something not parseable by java.net.URL — missing scheme, unresolved ${placeholder}, illegal characters, or empty string.","commonSituations":"Forgetting http:// in the annotation or yml; property key typo so ${shenyu.gateway} stays literal; leading/trailing spaces from YAML values; using a registry-style bare address where a full URL is required.","solutions":["Prefix the address with its scheme: url = \"http://localhost:9195\".","Define the referenced property so the placeholder resolves before registration.","Trim whitespace from the configured value.","Verify with a quick check in a test: new java.net.URL(resolvedUrl) should not throw."],"exampleFix":"// before\n@ShenyuClient(name = \"order\", url = \"localhost:9195\")\n// after\n@ShenyuClient(name = \"order\", url = \"http://localhost:9195\")","handlingStrategy":"validation","validationCode":"String url = env.resolvePlaceholders(clientUrl).trim();\ntry { new java.net.URL(url); }\ncatch (MalformedURLException e) {\n    throw new IllegalArgumentException(\"@ShenyuClient url invalid: \" + url, e);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always include the scheme (http:// or https://) in @ShenyuClient url values.","Centralize gateway addresses in properties and verify the keys exist per profile.","Run a startup check that java.net.URL-parses every configured client URL."],"tags":["url-validation","configuration","startup"],"backgroundTag":"invalid-url-format","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"}