{"record":{"id":"649ac65fae6f3b07","repo":"apache/beam","slug":"could-not-find-an-output-with-tag-for-the-transform","errorCode":null,"errorMessage":"Could not find an output with tag  for the transform ","messagePattern":"Could not find an output with tag  for the transform ","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/util/construction/TransformUpgrader.java","lineNumber":318,"sourceCode":"    // We record transforms that consume outputs of the old transform and update them to consume\n    // outputs of the new (upgraded) transform.\n    Collection<String> oldOutputs = transformToUpgrade.getOutputsMap().values();\n    Map<String, String> inputReplacements = new HashMap<>();\n    if (transformToUpgrade.getOutputsMap().size() == 1) {\n      inputReplacements.put(\n          oldOutputs.iterator().next(),\n          expandedTransform.getOutputsMap().values().iterator().next());\n    } else {\n      for (Map.Entry<String, String> entry : transformToUpgrade.getOutputsMap().entrySet()) {\n        if (!expandedTransform.getOutputsMap().keySet().contains(entry.getKey())) {\n          throw new IllegalArgumentException(\n              \"Original transform had an output with tag \"\n                  + entry.getKey()\n                  + \" but upgraded transform did not.\");\n        }\n        String newOutput = expandedTransform.getOutputsMap().get(entry.getKey());\n        if (newOutput == null) {\n          throw new IllegalArgumentException(\n              \"Could not find an output with tag \"\n                  + entry.getKey()\n                  + \" for the transform \"\n                  + expandedTransform);\n        }\n        inputReplacements.put(entry.getValue(), newOutput);\n      }\n    }\n\n    // The list of obsolete (overridden) transforms that should be removed from the pipeline\n    // produced by this method.\n    List<String> transformsToRemove = new ArrayList<>();\n    recursivelyFindSubTransforms(\n        transformId, runnerAPIpipeline.getComponents(), transformsToRemove);\n\n    Map<String, RunnerApi.PTransform> updatedExpandedTransformMap =\n        expandedComponents.getTransformsMap().entrySet().stream()\n            .filter(","sourceCodeStart":300,"sourceCodeEnd":336,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/util/construction/TransformUpgrader.java#L300-L336","documentation":"After verifying the tag exists in the expanded transform's outputsMap keySet, updateTransformViaTransformService looks up the replacement PCollection id via get(). If the map returns null (a mapping whose value is absent/empty), the upgrade cannot remap the original output to the new output, so an IllegalArgumentException naming the tag and expanded transform is thrown.","triggerScenarios":"Calling upgradeTransformsViaTransformService when the expanded transform's outputsMap contains the original tag as a key but the value (new PCollection id) is null or missing.","commonSituations":"Malformed response from the transform/expansion service; proto field cleared during serialization; service bug producing incomplete outputsMap values.","solutions":["Check the expanded transform proto returned by the transform service for a complete outputsMap (key AND non-empty value)","Fix or upgrade the transform service so it always fills in the new PCollection id for each output tag","Validate the expansion response before applying replacements"],"exampleFix":"// before: outputsMap = {out1: \"\"}\n// after: service returns outputsMap = {out1: \"pcollection_1\"}","handlingStrategy":"validation","validationCode":"for (Map.Entry<String, String> e : originalTransform.getOutputsMap().entrySet()) {\n  String newOutput = expandedTransform.getOutputsMap().get(e.getKey());\n  if (newOutput == null || newOutput.isEmpty()) {\n    throw new IllegalStateException(\"Missing replacement output for tag \" + e.getKey());\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  upgrader.upgradeTransformsViaTransformService(pipeline, ids, service);\n} catch (IllegalArgumentException e) {\n  // handle null replacement output from expansion service\n}","preventionTips":["Validate the expansion service response proto before applying it","Upgrade the transform service if outputsMap values are incomplete"],"tags":["java","beam","pipeline-construction","transform-upgrade"],"backgroundTag":"unexpected-response-shape","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}