{"record":{"id":"eaf4ea94d40359c9","repo":"apache/beam","slug":"unexpected-opt-v","errorCode":null,"errorMessage":"Unexpected opt: %v","messagePattern":"Unexpected opt: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/option.go","lineNumber":63,"sourceCode":"\tVar reflect.Type\n\t// T is the type it is bound to.\n\tT reflect.Type\n}\n\nfunc (s TypeDefinition) private() {}\n\nfunc parseOpts(opts []Option) ([]SideInput, []TypeDefinition) {\n\tvar side []SideInput\n\tvar infer []TypeDefinition\n\n\tfor _, opt := range opts {\n\t\tswitch opt := opt.(type) {\n\t\tcase SideInput:\n\t\t\tside = append(side, opt)\n\t\tcase TypeDefinition:\n\t\t\tinfer = append(infer, opt)\n\t\tdefault:\n\t\t\tpanic(fmt.Sprintf(\"Unexpected opt: %v\", opt))\n\t\t}\n\t}\n\treturn side, infer\n}\n","sourceCodeStart":45,"sourceCodeEnd":68,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/option.go#L45-L68","documentation":"parseOpts inspects each variadic Option passed to a Beam transform and only recognizes SideInput and TypeDefinition option types. Any other option implementation reaches the default case and panics with 'Unexpected opt: %v'. It signals that an Option type is not supported at the point where beam validates the transform.","triggerScenarios":"Passing an Option value that is neither SideInput nor TypeDefinition into a beam transform (e.g. beam.ParDo/beam.Impulse paths that call validate -> parseOpts), typically a custom or newly introduced Option type.","commonSituations":"A developer implements the Option interface themselves, or uses an option exported for a different transform family, or upgrades Beam where an option stopped being handled in parseOpts.","solutions":["Remove or replace the unsupported option with one of the accepted types (SideInput or TypeDefinition)","Check the Beam version/docs for the correct option helper for the transform being used","If implementing a custom Option, register/handle it in parseOpts or use a supported extension point instead"],"exampleFix":"// before\nbeam.ParDo(s, dofn, col, myCustomOpt{}) // panics: Unexpected opt\n// after\nbeam.ParDo(s, dofn, col) // only supported opts","handlingStrategy":"validation","validationCode":"for _, opt := range opts {\n    switch opt.(type) {\n    case beam.SideInput, beam.TypeDefinition:\n    default:\n        return fmt.Errorf(\"unsupported option %T\", opt)\n    }\n}","typeGuard":"func isSupportedOpt(o beam.Option) bool {\n    switch o.(type) {\n    case beam.SideInput, beam.TypeDefinition:\n        return true\n    }\n    return false\n}","tryCatchPattern":"defer func() {\n    if r := recover(); r != nil {\n        err = fmt.Errorf(\"beam option rejected: %v\", r)\n    }\n}()","preventionTips":["Only pass options obtained from Beam's exported helpers (beam.SideInput, type-definition options)","Do not implement the Option interface for custom types unless you also extend the transform plumbing","Pin and read the Beam version's option.go to see which options parseOpts accepts"],"tags":["go","beam","options","panic"],"backgroundTag":"unsupported-operation","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"}