apache/beam · error
res.GetError()
Error message
res.GetError()
What it means
When querying a cross-language expansion service, the ExpansionResponse may itself carry an error string instead of expanded components. QueryExpansionService wraps that string as an error with 'expansion response error' and expansion request context.
Source
Thrown at sdks/go/pkg/beam/core/runtime/xlangx/expand.go:191
retry.Attempts(maxRetries),
retry.DelayType(func(n uint, err error, config *retry.Config) time.Duration {
if n == 0 {
return time.Second
}
return retry.BackOffDelay(n, err, config)
}),
}
var res *jobpb.ExpansionResponse
err = retry.Do(func() error {
res, err = client.Expand(ctx, req)
return err
}, retryOpts...)
if err != nil {
err = errors.Wrap(err, "expansion failed")
return nil, errors.WithContextf(err, "expanding transform with ExpansionRequest: %v", req)
}
if len(res.GetError()) != 0 { // ExpansionResponse includes an error.
err := errors.New(res.GetError())
err = errors.Wrap(err, "expansion response error")
return nil, errors.WithContextf(err, "expanding transform with ExpansionRequest: %v", req)
}
return res, nil
}
func startAutomatedJavaExpansionService(gradleTarget string, classpath string) (stopFunc func() error, address string, err error) {
jarPath, err := expansionx.GetBeamJar(gradleTarget, core.SdkVersion)
if err != nil {
return nil, "", err
}
if len(classpath) > 0 {
jarPath, err = expansionx.MakeJar(jarPath, classpath)
if err != nil {
return nil, "", err
}View on GitHub (pinned to 12126d8942)
Solutions
- Read the wrapped expansion-service message; it names the failing URN/module on the service side
- Ensure the expansion service version matches the Beam SDK version (mismatched jars/wheels commonly cause this)
- For Python expansion, verify the transform module is importable in the service environment and dependencies are installed
- Run the expansion service manually with the same address to reproduce and see full service logs
- Pass retry/context options if the failure is transient service startup
Example fix
// diagnose the wrapped cause
res, err := xlangx.QueryExpansionService(ctx, req)
if err != nil {
var ec xlangx.ExpansionError
log.Fatalf("expansion failed: %v", err) // err message contains service-side cause
} Defensive patterns
Strategy: try-catch
Validate before calling
// preflight: verify expansion service is reachable and version-matched
resp, err := http.Get(expansionServiceAddr + "/health") // or grpc ping
if err != nil { return fmt.Errorf("expansion service unreachable at %s", expansionServiceAddr) } Try / catch
res, err := xlangx.QueryExpansionService(ctx, req)
if err != nil {
if strings.Contains(err.Error(), "expansion response error") {
log.Errorf("service-side failure: %v — check service logs for URN %s", err, req.GetUrn())
}
return err
} Prevention
- Match expansion service version to the Beam SDK version
- Pre-install transform dependencies in the expansion service environment
- Test external transforms against a locally started expansion service first
- Capture and read the wrapped service error message before escalating
When it happens
Trigger: Calling QueryExpansionService (or QueryAutomatedExpansionService / QueryPythonExpansionService) where the remote expansion service processes the ExpansionRequest but responds with res.Error set.
Common situations: Python expansion service failing to import the transform's module; Java expansion service URN not registered; version mismatch between the Beam Go SDK and the expansion service; missing external transform dependencies in the service's environment.
Related errors
- mismatched number of named outputs: received - %v expected -
- tried cross-language for %v against %v and failed
- Could not find coder for URN " + urn
- type annotation for multiple outputs is not allowed yet: %s
- invalid scope
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/7635c3eb82861163.
Report an issue: GitHub.