{"record":{"id":"017639eefa9510cc","repo":"apache/beam","slug":"expansion-request-to-transform-service-failed","errorCode":null,"errorMessage":"Expansion request to transform service failed.","messagePattern":"Expansion request to transform service failed\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"sdks/java/transform-service/src/main/java/org/apache/beam/sdk/transformservice/ExpansionService.java","lineNumber":198,"sourceCode":"    // Trying out expansion services in order till one succeeds.\n    // If all services fail, re-raises the last error.\n    Map<String, ExpansionResponse> errorResponses = new HashMap<>();\n    RuntimeException lastException = null;\n    for (Endpoints.ApiServiceDescriptor endpoint : endpoints) {\n      try {\n        ExpansionApi.ExpansionResponse response =\n            expansionServiceClientFactory.getExpansionServiceClient(endpoint).expand(request);\n        if (!response.getError().isEmpty()) {\n          errorResponses.put(endpoint.getUrl(), response);\n          continue;\n        }\n        return response;\n      } catch (RuntimeException e) {\n        lastException = e;\n      }\n    }\n    if (lastException != null) {\n      throw new RuntimeException(\"Expansion request to transform service failed.\", lastException);\n    }\n    if (!errorResponses.isEmpty()) {\n      return getAggregatedErrorResponse(errorResponses);\n    } else if (lastException != null) {\n      throw new RuntimeException(\"Expansion request to transform service failed.\", lastException);\n    } else {\n      throw new RuntimeException(\"Could not process the expansion request: \" + request);\n    }\n  }\n\n  ExpansionApi.DiscoverSchemaTransformResponse processDiscover(\n      ExpansionApi.DiscoverSchemaTransformRequest request) {\n    // Trying out expansion services and aggregating all successful results.\n    // If all services fail, return the last successful response any.\n    // If there are no successful responses, re-raises the last error.\n    List<ExpansionApi.DiscoverSchemaTransformResponse> successfulResponses = new ArrayList<>();\n    ExpansionApi.DiscoverSchemaTransformResponse lastErrorResponse = null;\n    for (Endpoints.ApiServiceDescriptor endpoint : endpoints) {","sourceCodeStart":180,"sourceCodeEnd":216,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/transform-service/src/main/java/org/apache/beam/sdk/transformservice/ExpansionService.java#L180-L216","documentation":"Thrown by ExpansionService.processExpand after the client failed to obtain a successful expansion response from any configured transform service endpoint. All candidate expansion services either raised RuntimeExceptions or returned errors, so the last exception is rethrown with the generic message. The original cause is attached, so inspect getCause() for the real failure.","triggerScenarios":"Calling expansion (e.g. via pipeline.apply with an external transform resolved by a transform service) when every configured expansion service endpoint throws a RuntimeException during the request/receive cycle — e.g. service down, gRPC failure, or malformed response.","commonSituations":"Transform service container not running or unreachable; wrong expansion service address in the config; network/firewall blocking the gRPC port; service crashing mid-expansion; incompatible Beam SDK/service versions.","solutions":["Read the chained cause (e.getCause()) to find the actual failure from the expansion service call.","Verify the expansion service endpoint(s) in the Transform Service config YAML are reachable (host/port, no firewall block).","Ensure the transform service is started and healthy before submitting the pipeline.","Check that SDK and expansion service versions match."],"exampleFix":"// before: opaque failure\nthrow new RuntimeException(\"Expansion request to transform service failed.\", lastException);\n// after: surface cause and check service availability first\nif (lastException != null) {\n  throw new RuntimeException(\n      \"Expansion request to transform service failed: \" + lastException.getMessage(), lastException);\n}","handlingStrategy":"try-catch","validationCode":"// before expansion, check endpoints are reachable\nfor (String ep : expansionServiceEndpoints) {\n  String[] hp = ep.split(\":\");\n  try (java.net.Socket s = new java.net.Socket(hp[0], Integer.parseInt(hp[1]))) {\n    // reachable\n  } catch (IOException e) {\n    throw new IllegalStateException(\"Expansion service unreachable: \" + ep, e);\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  expansionResult = expansionService.expand(request);\n} catch (RuntimeException e) {\n  Throwable root = e;\n  while (root.getCause() != null) root = root.getCause();\n  LOG.error(\"Expansion failed; root cause: {}\", root.getMessage(), root);\n  throw new IllegalStateException(\"Transform service unreachable or failed; root cause: \" + root.getMessage(), e);\n}","preventionTips":["Start the transform service and health-check the endpoint before submitting the pipeline.","Use absolute, verified host:port addresses in the config YAML.","Keep SDK and expansion service versions aligned."],"tags":["java","grpc","network","expansion-service"],"backgroundTag":"api-request-failed","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"}