{"record":{"id":"46cbc9a2255a972e","repo":"apache/beam","slug":"specified-path-s-already-used-for-subcomponent-s","errorCode":null,"errorMessage":"Specified path '%s' already used for subcomponent %s. Subcomponents must be included using unique paths.","messagePattern":"Specified path '(.+?)' already used for subcomponent (.+?)\\. Subcomponents must be included using unique paths\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/display/DisplayData.java","lineNumber":727,"sourceCode":"    private @Nullable Path latestPath;\n    private @Nullable Class<?> latestNs;\n\n    private InternalBuilder() {\n      this.entries = Maps.newHashMap();\n      this.visitedComponents = Sets.newIdentityHashSet();\n      this.visitedPathMap = Maps.newHashMap();\n    }\n\n    @Override\n    public Builder include(String path, HasDisplayData subComponent) {\n      checkNotNull(subComponent, \"subComponent argument cannot be null\");\n      checkNotNull(path, \"path argument cannot be null\");\n\n      Path absolutePath = latestPath.extend(path);\n\n      HasDisplayData existingComponent = visitedPathMap.get(absolutePath);\n      if (existingComponent != null) {\n        throw new IllegalArgumentException(\n            String.format(\n                \"Specified path '%s' already used for \"\n                    + \"subcomponent %s. Subcomponents must be included using unique paths.\",\n                path, existingComponent));\n      }\n\n      return include(absolutePath, subComponent);\n    }\n\n    @Override\n    public Builder delegate(HasDisplayData component) {\n      checkNotNull(component);\n\n      return include(latestPath, component);\n    }\n\n    private Builder include(Path path, HasDisplayData subComponent) {\n      if (visitedComponents.contains(subComponent)) {","sourceCodeStart":709,"sourceCodeEnd":745,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/display/DisplayData.java#L709-L745","documentation":"When a component includes subcomponents via includeSubcomponent(), each subcomponent must be registered under a unique path. Beam tracks visited components by absolute path; if the same path is reused for a different subcomponent, it throws an IllegalArgumentException with this message to prevent ambiguous display-data hierarchies.","triggerScenarios":"Calling builder.include(\"key\", subComponent1) and later builder.include(\"key\", subComponent2) in the same populateDisplayData tree, or including the same path in a loop where the path argument is constant instead of indexed.","commonSituations":"Looping over a list of sub-transforms and calling include(\"subcomponent\", x) with the same literal path each iteration; merging display data from multiple sources that reuse path names.","solutions":["Make each path unique, e.g. include(\"subcomponent-\" + i, subComponent) in loops","Audit includeSubcomponent calls for duplicated literal path strings","Namespace paths by component class or instance id","Add a unit test asserting populateDisplayData runs without IllegalArgumentException"],"exampleFix":"// before\nfor (Transform t : transforms) { builder.include(\"subcomponent\", t); }\n// after\nfor (int i = 0; i < transforms.size(); i++) { builder.include(\"subcomponent-\" + i, transforms.get(i)); }","handlingStrategy":"validation","validationCode":"Set<String> usedPaths = new HashSet<>();\nString path = ...;\nif (!usedPaths.add(path)) { throw new IllegalStateException(\"Duplicate subcomponent path: \" + path); }","typeGuard":null,"tryCatchPattern":"try { builder.include(path, subComponent); } catch (IllegalArgumentException e) { /* log duplicate path and skip */ }","preventionTips":["Generate paths with indices/ids when including subcomponents in loops","Never reuse literal path strings across includeSubcomponent calls","Test populateDisplayData for transforms with multiple subcomponents"],"tags":["beam","display-data","duplicate-path","api-misuse"],"backgroundTag":"duplicate-component-path","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}