{"record":{"id":"4b9b849aed34aa14","repo":"alibaba/spring-cloud-alibaba","slug":"illegal-uri-uris","errorCode":null,"errorMessage":"illegal URI: {uris}","messagePattern":"illegal URI: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"spring-cloud-alibaba-starters/spring-alibaba-nacos-config/src/main/java/com/alibaba/cloud/nacos/configdata/NacosConfigDataLocationResolver.java","lineNumber":240,"sourceCode":"\t\t\tConfigDataLocationResolverContext resolverContext) {\n\t\tList<?> springConfigImportProperties = resolverContext.getBinder()\n\t\t\t\t.bind(SPRING_CONFIG_IMPORT_PROPERTIES, List.class).get();\n\t\tif (!springConfigImportProperties.isEmpty() && !bootstrapContext.isRegistered(NacosConfigManager.class)) {\n\t\t\tbootstrapContext.register(NacosConfigManager.class,\n\t\t\t\t\tBootstrapRegistry.InstanceSupplier.of(NacosConfigManager.getInstance(properties)));\n\t\t}\n\t}\n\n\tprivate URI getUri(String uris) {\n\t\tif (!uris.startsWith(\"http://\") && !uris.startsWith(\"https://\")) {\n\t\t\turis = \"http://\" + uris;\n\t\t}\n\t\tURI uri;\n\t\ttry {\n\t\t\turi = new URI(uris);\n\t\t}\n\t\tcatch (URISyntaxException e) {\n\t\t\tthrow new IllegalArgumentException(\"illegal URI: \" + uris);\n\t\t}\n\t\treturn uri;\n\t}\n\n\tprivate @Nullable String groupFor(URI uri, NacosConfigProperties properties) {\n\t\tMap<String, String> queryMap = getQueryMap(uri);\n\t\treturn queryMap.containsKey(GROUP) ? queryMap.get(GROUP) : properties.getGroup();\n\t}\n\n\tprivate Map<String, String> getQueryMap(URI uri) {\n\t\tString query = uri.getQuery();\n\t\tif (StringUtils.isBlank(query)) {\n\t\t\treturn Collections.emptyMap();\n\t\t}\n\t\tMap<String, String> result = new HashMap<>(4);\n\t\tfor (String entry : query.split(\"&\")) {\n\t\t\tString[] kv = entry.split(\"=\");\n\t\t\tif (kv.length == 2) {","sourceCodeStart":222,"sourceCodeEnd":258,"githubUrl":"https://github.com/alibaba/spring-cloud-alibaba/blob/115d5901102009492e05d5ec18c3f79cad4077d0/spring-cloud-alibaba-starters/spring-alibaba-nacos-config/src/main/java/com/alibaba/cloud/nacos/configdata/NacosConfigDataLocationResolver.java#L222-L258","documentation":"Thrown by NacosConfigDataLocationResolver.getUri when new URI(uris) raises URISyntaxException. The method first prepends 'http://' when the string lacks a scheme, then parses; if the resulting string is still not a valid URI (illegal characters, malformed host, bad percent-encoding, stray spaces), parsing fails and IllegalArgumentException(\"illegal URI: <value>\") is thrown.","triggerScenarios":"A spring.config.import nacos: value that, after http:// prepending, is not parseable as a URI — e.g., unencoded spaces, an invalid port, mismatched brackets, a malformed host, or illegal characters in the dataId/query.","commonSituations":"Paste errors with spaces in the import string; non-URL-encoded special characters; a missing/extra colon; a server-addr with brackets or commas copied from a cluster config without encoding.","solutions":["Correct the import string: ensure host:port and dataId are well-formed and percent-encode spaces/special chars.","Keep server-addr in spring.cloud.nacos.config.server-addr and the import minimal: `nacos:app.yml`.","If a cluster address list is needed, use the standard form and avoid illegal characters in the URI.","Validate the string with new URI(...) locally to find the offending character."],"exampleFix":"# before (space / illegal char)\nspring.config.import: \"nacos://my host:8848/app.yml\"\n# after\nspring.cloud.nacos.config.server-addr: my-host:8848\nspring.config.import: \"nacos:app.yml\"","handlingStrategy":"validation","validationCode":"// Validate the import string parses as a URI before relying on config-data import.\nString raw = importValue;\nif (!raw.startsWith(\"http://\") && !raw.startsWith(\"https://\")) raw = \"http://\" + raw;\ntry { new URI(raw); } catch (URISyntaxException e) { /* reject, show offending chars */ }","typeGuard":"static boolean isParsableNacosUri(String uris) {\n    if (uris == null) return false;\n    String s = (!uris.startsWith(\"http://\") && !uris.startsWith(\"https://\")) ? \"http://\" + uris : uris;\n    try { new URI(s); return true; } catch (URISyntaxException e) { return false; }\n}","tryCatchPattern":null,"preventionTips":["Keep server-addr in spring.cloud.nacos.config.server-addr and the import minimal.","Percent-encode spaces and special characters.","Avoid cluster address lists with illegal URI characters."],"tags":["nacos","config-data","spring-boot","config-import","uri","misconfiguration"],"backgroundTag":null,"analyzedSha":"115d5901102009492e05d5ec18c3f79cad4077d0","analyzedAt":"2026-08-14T04:47:13.900Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}