{"record":{"id":"8ab75054ef4a0d12","repo":"alibaba/spring-cloud-alibaba","slug":"illegal-dataid","errorCode":null,"errorMessage":"illegal dataId","messagePattern":"illegal dataId","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":288,"sourceCode":"\t\treturn properties.getFileExtension();\n\t}\n\n\tprivate boolean refreshEnabledFor(URI uri, NacosConfigProperties properties) {\n\t\tMap<String, String> queryMap = getQueryMap(uri);\n\t\treturn queryMap.containsKey(REFRESH_ENABLED)\n\t\t\t\t? Boolean.parseBoolean(queryMap.get(REFRESH_ENABLED))\n\t\t\t\t: properties.isRefreshEnabled();\n\t}\n\n\tprivate @Nullable String dataIdFor(URI uri) {\n\t\tString path = uri.getPath();\n\t\t// notice '/'\n\t\tif (path == null || path.length() <= 1) {\n\t\t\treturn StringUtils.EMPTY;\n\t\t}\n\t\tString[] parts = path.substring(1).split(\"/\");\n\t\tif (parts.length != 1) {\n\t\t\tthrow new IllegalArgumentException(\"illegal dataId\");\n\t\t}\n\t\treturn parts[0];\n\t}\n\n}\n","sourceCodeStart":270,"sourceCodeEnd":294,"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#L270-L294","documentation":"Thrown by NacosConfigDataLocationResolver.dataIdFor when the URI path, after stripping the leading '/', splits into more than one segment (parts.length != 1). A valid nacos import path must be a single segment (the dataId, e.g., '/app.yml'); a path like '/a/b' or '/dir/app.yml' has multiple segments and is rejected because dataId cannot encode a multi-segment path.","triggerScenarios":"A nacos: import whose path contains slashes beyond the leading one — e.g., `nacos:dir/app.yml`, `nacos://host/a/b`, or `nacos:folder/sub/app.yml`. dataIdFor splits and sees >1 segment.","commonSituations":"Treating the Nacos dataId like a filesystem path with directories; grouping configs into nested-looking import strings; copying a path from elsewhere.","solutions":["Use a flat dataId (Nacos dataIds are not hierarchical): `nacos:app.yml` or `nacos://host/app.yml`.","If you need disambiguation, use distinct dataId names or the group query param instead of path segments.","Remove any '/' inside the dataId portion of the import."],"exampleFix":"# before\nspring.config.import: \"nacos:orders/app.yml\"\n# after\nspring.config.import: \"nacos:orders-app.yml?group=ORDER_GROUP\"","handlingStrategy":"validation","validationCode":"// Ensure the dataId path is a single segment (no nested slashes).\nString path = uri.getPath();\nif (path == null || path.length() <= 1 || path.substring(1).split(\"/\").length != 1) {\n    // reject: dataId must be flat\n}","typeGuard":"static boolean isFlatDataIdPath(String path) {\n    if (path == null || path.length() <= 1) return false;\n    return path.substring(1).split(\"/\").length == 1;\n}","tryCatchPattern":null,"preventionTips":["Use flat Nacos dataIds (no slashes inside).","Use group/query params for disambiguation, not path nesting.","Lint import paths at startup."],"tags":["nacos","config-data","spring-boot","config-import","dataid","misconfiguration"],"backgroundTag":null,"analyzedSha":"115d5901102009492e05d5ec18c3f79cad4077d0","analyzedAt":"2026-08-14T04:47:13.900Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}