{"record":{"id":"9bee4aefa07a83df","repo":"apache/beam","slug":"inputs-already-set-as-v","errorCode":null,"errorMessage":"inputs already set as: \n%v","messagePattern":"inputs already set as: \n(.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"sdks/go/pkg/beam/core/graph/xlang.go","lineNumber":80,"sourceCode":"// Expanded field.\ntype ExternalTransform struct {\n\tNamespace string\n\n\tUrn           string\n\tPayload       []byte\n\tExpansionAddr string\n\n\tInputsMap  map[string]int\n\tOutputsMap map[string]int\n\n\tExpanded *ExpandedTransform\n}\n\n// WithNamedInputs adds a map (tag -> index of Inbound in MultiEdge.Input)\n// of named inputs corresponsing to ExternalTransform's InputsMap\nfunc (ext ExternalTransform) WithNamedInputs(inputsMap map[string]int) ExternalTransform {\n\tif ext.InputsMap != nil {\n\t\tpanic(errors.Errorf(\"inputs already set as: \\n%v\", ext.InputsMap))\n\t}\n\text.InputsMap = inputsMap\n\treturn ext\n}\n\n// WithNamedOutputs adds a map (tag -> index of Outbound in MultiEdge.Output)\n// of named outputs corresponsing to ExternalTransform's OutputsMap\nfunc (ext ExternalTransform) WithNamedOutputs(outputsMap map[string]int) ExternalTransform {\n\tif ext.OutputsMap != nil {\n\t\tpanic(errors.Errorf(\"outputTypes already set as: \\n%v\", ext.OutputsMap))\n\t}\n\text.OutputsMap = outputsMap\n\treturn ext\n}\n\n// NewNamespaceGenerator returns a functions that generates a random string of n alphabets\nfunc NewNamespaceGenerator(n int) func() string {\n\tconst letters = \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\"","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/graph/xlang.go#L62-L98","documentation":"ExternalTransform.WithNamedInputs sets the tag→input-index map used for cross-language transforms. It is a builder method that must be called at most once; calling it again on an ExternalTransform whose InputsMap is already non-nil panics with 'inputs already set as: ...'.","triggerScenarios":"Calling WithNamedInputs twice on the same ExternalTransform value (e.g. in a loop or builder chain repeated by mistake), before expanding the external transform.","commonSituations":"Builder-style code that applies WithNamedInputs in both a helper and the caller; retry/re-application logic re-running the builder; accidental method chaining duplication.","solutions":["Call WithNamedInputs exactly once per ExternalTransform; drop the duplicate call.","If inputs may vary, create a fresh ExternalTransform (e.g. via beam.CrossLanguage/payload constructor) before calling WithNamedInputs.","Guard builder code: only invoke when InputsMap is nil.","The panic message prints the existing map — compare it with the intended inputsMap to spot the conflicting call site."],"exampleFix":"// before\next = ext.WithNamedInputs(m)\next = ext.WithNamedInputs(m) // panics\n// after\nif ext.InputsMap == nil {\n    ext = ext.WithNamedInputs(m)\n}","handlingStrategy":"validation","validationCode":"if ext.InputsMap == nil {\n    ext = ext.WithNamedInputs(inputsMap)\n}","typeGuard":null,"tryCatchPattern":"func safeWithInputs(ext graph.ExternalTransform, m map[string]int) (r graph.ExternalTransform) {\n    defer func() { if rec := recover(); rec != nil { log.Printf(\"inputs already set: %v\", rec) } }()\n    return ext.WithNamedInputs(m)\n}","preventionTips":["Apply builder methods in exactly one place, not in helpers and callers.","Never re-run builder chains on a retained ExternalTransform value."],"tags":["beam","go","xlang","builder","panic"],"backgroundTag":"conflicting-config-options","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T21:17:11.552Z"}