{"record":{"id":"5014a1340a7e899b","repo":"apache/beam","slug":"empty-port","errorCode":null,"errorMessage":"empty port","messagePattern":"empty port","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"sdks/go/pkg/beam/core/runtime/harness/datamgr.go","lineNumber":115,"sourceCode":"\ts.mu.Lock()\n\tdefer s.mu.Unlock()\n\ts.closed = true\n\terr := s.mgr.closeInstruction(s.instID, s.openPorts)\n\ts.mgr = nil\n\treturn err\n}\n\n// DataChannelManager manages data channels over the Data API. A fixed number of channels\n// are generally used, each managing multiple logical byte streams. Thread-safe.\ntype DataChannelManager struct {\n\tports map[string]*DataChannel\n\tmu    sync.Mutex // guards the ports map\n}\n\n// Open opens a R/W DataChannel over the given port.\nfunc (m *DataChannelManager) Open(ctx context.Context, port exec.Port) (*DataChannel, error) {\n\tif port.URL == \"\" {\n\t\tpanic(\"empty port\")\n\t}\n\n\tm.mu.Lock()\n\tdefer m.mu.Unlock()\n\n\tif m.ports == nil {\n\t\tm.ports = make(map[string]*DataChannel)\n\t}\n\tif con, ok := m.ports[port.URL]; ok {\n\t\treturn con, nil\n\t}\n\n\tch, err := newDataChannel(ctx, port)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tch.forceRecreate = func(id string, err error) {\n\t\tswitch status.Code(err) {","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/runtime/harness/datamgr.go#L97-L133","documentation":"DataChannelManager.Open establishes a read/write gRPC data channel to the Beam runner's data service, which is addressed via port.URL. An empty URL means the harness was given no usable logging/data API endpoint, so the manager panics instead of dialing a meaningless address.","triggerScenarios":"Calling DataChannelManager.Open with an exec.Port whose URL field is \"\" — typically when the harness bootstrap passed an empty --loggingEndpoint/--dataEndpoint or the pipeline options omitted the data API service address.","commonSituations":"Running a Go Beam worker outside the runner-managed environment (custom container, Flink/Spark/Spark runner misconfiguration) where the endpoint environment variables are missing; typo'd pipeline option that blanks the port URL; unit-testing the harness with a zero-value exec.Port.","solutions":["Ensure the runner passes the data endpoint: check that the worker is launched with the correct --workerHarnessContainerImage and endpoint pipeline options.","When testing/using the harness directly, populate exec.Port{URL: \"host:port\"} (e.g. from the environment variable the runner sets) before calling Open.","If launching containers manually, set the RUNNER/BEAM harness endpoint env or flags exactly as the runner expects."],"exampleFix":"// before\nch, err := mgr.Open(ctx, exec.Port{})\n// after\nif port.URL == \"\" {\n    return nil, fmt.Errorf(\"data endpoint URL not configured\")\n}\nch, err := mgr.Open(ctx, port)","handlingStrategy":"validation","validationCode":"if port.URL == \"\" {\n    return fmt.Errorf(\"data channel port URL is empty; check runner endpoint configuration\")\n}","typeGuard":null,"tryCatchPattern":"defer func() {\n    if r := recover(); r != nil {\n        log.Fatalf(\"failed to open data channel: %v\", r)\n    }\n}()","preventionTips":["Verify runner-provided endpoint flags/env before launching workers","Never pass a zero-value exec.Port to Open","Log the resolved port URL at worker startup for diagnosis"],"tags":["go","apache-beam","grpc","harness","panic"],"backgroundTag":"missing-env-var","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"}