{"record":{"id":"1212191820b50799","repo":"apache/beam","slug":"error-in-startautomatedpythonexpansionservice-s-s-w","errorCode":null,"errorMessage":"error in  startAutomatedPythonExpansionService(%s,%s): %w","messagePattern":"error in  startAutomatedPythonExpansionService\\((.+?),(.+?)\\): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/runtime/xlangx/expand.go","lineNumber":283,"sourceCode":"\t}\n\n\t// Restore tag so we know the artifacts have been materialized eagerly down the road.\n\tp.edge.External.ExpansionAddr = tag + Separator + target\n\n\t// Can return the original response because all of our proto modification afterwards has\n\t// been via pointer.\n\treturn res, nil\n}\n\nfunc startPythonExpansionService(service, extraPackage string) (stopFunc func() error, address string, err error) {\n\tvenvPython, err := expansionx.SetUpPythonEnvironment(extraPackage)\n\tif err != nil {\n\t\treturn nil, \"\", err\n\t}\n\n\tserviceRunner, err := expansionx.NewPyExpansionServiceRunner(venvPython, service, \"\")\n\tif err != nil {\n\t\treturn nil, \"\", fmt.Errorf(\"error in  startAutomatedPythonExpansionService(%s,%s): %w\", venvPython, service, err)\n\t}\n\terr = serviceRunner.StartService()\n\tif err != nil {\n\t\treturn nil, \"\", fmt.Errorf(\"error in starting expansion service, StartService(): %w\", err)\n\t}\n\tstopFunc = serviceRunner.StopService\n\taddress = serviceRunner.Endpoint()\n\treturn stopFunc, address, nil\n}\n\n// QueryPythonExpansionService submits an external python transform to be expanded by the\n// expansion service and then eagerly materializes the artifacts for staging. The given\n// transform should be the external transform, and the components are any additional\n// components necessary for the pipeline snippet.\n//\n// The address to be queried is determined by the Config field of the HandlerParams after\n// the prefix tag indicating the automated service is in use.\nfunc QueryPythonExpansionService(ctx context.Context, p *HandlerParams) (*jobpb.ExpansionResponse, error) {","sourceCodeStart":265,"sourceCodeEnd":301,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/runtime/xlangx/expand.go#L265-L301","documentation":"This error is returned by startPythonExpansionService when expansionx.NewPyExpansionServiceRunner fails to construct a runner object that would launch an automated Python expansion service subprocess. The library wraps the underlying cause (typically a failed exec.LookPath or bad argument combination) so callers know the failure occurred during runner creation, not service startup. The %s,%s arguments log the venv Python binary path and the service module spec that were passed in.","triggerScenarios":"QueryPythonExpansionService -> startPythonExpansionService with a venvPython path that does not exist or is not executable, or a service spec string NewPyExpansionServiceRunner rejects.","commonSituations":"A virtualenv was deleted or moved after being configured; BEAM Python SDK path misconfigured; passing a fully-qualified expansion service address when the runner expects a module name; Go worker running in a container without the Python venv installed.","solutions":["Verify the venvPython path exists and is executable (run `<venvPython> --version` manually).","Check the service argument matches the expected module spec (e.g. apache_beam.runners.portability.expansion_service_main) for the installed Beam Python version.","Inspect the wrapped cause (%w) in the error chain for the real underlying failure.","Recreate the Python virtualenv and reinstall apache_beam to restore the expansion service entry point."],"exampleFix":"// before\nstopFunc, addr, err := xlangx.QueryPythonExpansionService(ctx, \"venv\", \"python3\", service)\n// after\nif _, err := os.Stat(venvPython); err != nil {\n    return fmt.Errorf(\"venv python missing at %s: %w\", venvPython, err)\n}\nstopFunc, addr, err := xlangx.QueryPythonExpansionService(ctx, venvPython, service)","handlingStrategy":"validation","validationCode":"if fi, err := os.Stat(venvPython); err != nil || fi.IsDir() {\n    return fmt.Errorf(\"venv python not usable at %s: %v\", venvPython, err)\n}\nif out, err := exec.Command(venvPython, \"--version\").CombinedOutput(); err != nil {\n    return fmt.Errorf(\"venv python not runnable: %v: %s\", err, out)\n}","typeGuard":null,"tryCatchPattern":"if stopFunc, addr, err := xlangx.QueryPythonExpansionService(ctx, venvPython, service); err != nil {\n    var inner error\n    if errors.Unwrap(err) != nil { inner = errors.Unwrap(err) }\n    log.Printf(\"expansion runner init failed: %v (cause: %v)\", err, inner)\n    return err\n}","preventionTips":["Verify the venv python binary exists and executes before starting cross-language pipelines.","Pin apache_beam version in the venv to match the Beam Go SDK version.","Log venvPython and service args in pipeline setup for debuggability."],"tags":["go","subprocess","expansion-service","cross-language"],"backgroundTag":"module-init-failed","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}