{"record":{"id":"4e05af9adde2c36e","repo":"apache/shenyu","slug":"is-malformed","errorCode":null,"errorMessage":" is malformed","messagePattern":" is malformed","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"shenyu-sdk/shenyu-sdk-feign/src/main/java/org/apache/shenyu/sdk/feign/ShenyuClientsRegistrar.java","lineNumber":409,"sourceCode":"\n    /**\n     * Gets url.\n     * @param url the url\n     * @return the url\n     */\n    static String getUrl(final String url) {\n        String resultUrl = url;\n        if (StringUtils.hasText(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        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\n    /**\n     * Gets path.\n     * @param path the path","sourceCodeStart":391,"sourceCodeEnd":427,"githubUrl":"https://github.com/apache/shenyu/blob/567142e07261b3e615ae8850b30f4421f455cc5d/shenyu-sdk/shenyu-sdk-feign/src/main/java/org/apache/shenyu/sdk/feign/ShenyuClientsRegistrar.java#L391-L427","documentation":"ShenyuClientsRegistrar.getUrl() resolves the @ShenyuClient url attribute (possibly from a property placeholder), strips any trailing slash, and validates it with java.net.URL. If the resolved string is not a well-formed URL, it throws IllegalArgumentException wrapping the MalformedURLException. This fails fast at bean-registration time instead of letting the client fail on its first request.","triggerScenarios":"Registering a @ShenyuClient (feign SDK) whose url attribute resolves, after placeholder substitution, to a string java.net.URL cannot parse — e.g. \"localhost:8080\" (no scheme), \"http//host\", \"${gateway.url}\" left unresolved, or an empty/whitespace value.","commonSituations":"Typo in the url scheme in application.yml; referencing a property that does not exist so the raw placeholder string is passed through; forgetting the http:// prefix; copying a URL with stray characters from docs.","solutions":["Add the scheme prefix, e.g. change url = \"localhost:9195\" to url = \"http://localhost:9195\".","Ensure the property referenced by ${...} exists in the environment (application.yml, env var) so the placeholder resolves.","Print/log the resolved value and fix the exact malformed segment reported in the message (it is prefixed to the error).","If the target is not a full URL, use the configured serverList/registerType=local discovery path instead of a static url."],"exampleFix":"// before\n@ShenyuClient(name = \"order\", url = \"${shenyu.gateway}\") // shenyu.gateway=localhost:9195\n// after\n@ShenyuClient(name = \"order\", url = \"${shenyu.gateway}\") // shenyu.gateway=http://localhost:9195","handlingStrategy":"validation","validationCode":"String url = env.resolvePlaceholders(clientUrl);\nif (url == null || url.isBlank() || !url.matches(\"^https?://[^\\s]+\")) {\n    throw new IllegalArgumentException(\"@ShenyuClient url must be a full http(s) URL, got: \" + url);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always use fully-qualified http(s) URLs in @ShenyuClient url attributes.","Keep gateway URLs in application.yml so placeholders resolve in one place.","Add a startup test that resolves and validates every 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"}