{"record":{"id":"bdd4cf3e2ccff578","repo":"apache/beam","slug":"internal-error","errorCode":null,"errorMessage":"internal error","messagePattern":"internal error","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/create.go","lineNumber":108,"sourceCode":"\n\tfor i, value := range values {\n\t\tif other := reflect.ValueOf(value).Type(); other != t {\n\t\t\terr := errors.Errorf(\"value %v at index %v has type %v, want %v\", value, i, other, t)\n\t\t\treturn PCollection{}, addCreateCtx(err, s)\n\t\t}\n\t\tvar buf bytes.Buffer\n\t\tif err := enc.Encode(value, &buf); err != nil {\n\t\t\terr = errors.Wrapf(err, \"marshalling of %v failed\", value)\n\t\t\treturn PCollection{}, addCreateCtx(err, s)\n\t\t}\n\t\tfn.Values = append(fn.Values, buf.Bytes())\n\t}\n\n\timp := Impulse(s)\n\n\tret, err := TryParDo(s, fn, imp, TypeDefinition{Var: TType, T: t})\n\tif err != nil || len(ret) != 1 {\n\t\tpanic(addCreateCtx(errors.WithContext(err, \"internal error\"), s))\n\t}\n\treturn ret[0], nil\n}\n\n// TODO(herohde) 6/26/2017: make 'create' a SDF once supported. See BEAM-2421.\n\ntype createFn struct {\n\tValues [][]byte    `json:\"values\"`\n\tType   EncodedType `json:\"type\"`\n}\n\nfunc (c *createFn) ProcessElement(_ []byte, emit func(T)) error {\n\tdec := NewElementDecoder(c.Type.T)\n\tfor _, val := range c.Values {\n\t\telement, err := dec.Decode(bytes.NewBuffer(val))\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/create.go#L90-L126","documentation":"beam.createList creates a PCollection from a Go value by running a ParDo over an impulse. If the internal ParDo fails or does not return exactly one output, the library treats it as an unrecoverable internal invariant violation and panics with 'internal error' plus any underlying context.","triggerScenarios":"Calling beam.Create/CreateList with a type that the internal TryParDo cannot process (e.g. an unsupported element type or coder failure), producing err != nil or len(ret) != 1.","commonSituations":"Passing types that fail schema/coder inference to beam.Create in a pipeline; a Beam SDK bug rather than user code, but usually surfaced via unusual element types.","solutions":["Inspect the wrapped addCreateCtx context in the panic message for the root cause and fix the element type.","Simplify the value passed to beam.Create (use a basic serializable type) to isolate the failure.","If it persists, report it as a Beam SDK bug with the failing type; this panic is not expected for valid inputs."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"if err := beam.TryCreate(s, value) == nil check; err != nil { ... } // prefer TryCreate for error return","typeGuard":null,"tryCatchPattern":"func safeCreate(s beam.Scope, v any) (col beam.PCollection, err error) {\n    defer func() {\n        if r := recover(); r != nil {\n            err = fmt.Errorf(\"create failed: %v\", r)\n        }\n    }()\n    return beam.Create(s, v), nil\n}","preventionTips":["Use beam.TryCreate/TryCreateList when you need an error instead of a panic.","Keep element types simple and serializable for beam.Create."],"tags":["go","apache-beam","internal-error"],"backgroundTag":"internal-invariant-violation","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}