{"record":{"id":"841b180d8f864f2f","repo":"apache/beam","slug":"failed-to-match-optional-parameter-v","errorCode":null,"errorMessage":"failed to match optional parameter %v","messagePattern":"failed to match optional parameter (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/funcx/signature.go","lineNumber":223,"sourceCode":"}\n\nfunc matchOpt(list, models []reflect.Type, m map[string]reflect.Type) error {\n\ti := 0\n\tfor _, t := range list {\n\t\tif typex.IsUniversal(t) {\n\t\t\t// Substitute optional types, if bound.\n\t\t\tsubst, ok := m[t.Name()]\n\t\t\tif !ok {\n\t\t\t\treturn errors.Errorf(\"optional generic parameter not bound %v\", t.Name())\n\t\t\t}\n\t\t\tt = subst\n\t\t}\n\t\tfor i < len(models) && models[i] != t {\n\t\t\ti++\n\t\t}\n\n\t\tif i == len(models) {\n\t\t\treturn errors.Errorf(\"failed to match optional parameter %v\", t)\n\t\t}\n\t}\n\treturn nil\n}\n\n// MustSatisfy panics if the given fn does not satisfy the signature.\nfunc MustSatisfy(fn any, sig *Signature) {\n\tif err := Satisfy(fn, sig); err != nil {\n\t\tpanic(errors.Wrapf(err, \"fn does not satisfy signature %v\", sig))\n\t}\n}\n","sourceCodeStart":205,"sourceCodeEnd":235,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/funcx/signature.go#L205-L235","documentation":"matchOpt walks the function's optional parameters in order, matching each against the signature's optional model list. This error is returned when an optional parameter's type does not appear anywhere (further) in the model list, i.e. the function has an optional parameter the signature does not offer.","triggerScenarios":"Calling Satisfy with a function whose optional parameter type (after generic substitution) is not in sig.OptArgs/OptReturn models, e.g. a DoFn method taking an extra optional emit<X> that the signature's optional list lacks.","commonSituations":"Adding an optional context/counter/emitter parameter to a DoFn method without updating the Signature; wrong parameter order so matching runs past the available models; a signature built for a different variant of the function.","solutions":["Remove the unmatched optional parameter from the function.","Add the corresponding optional model to sig.OptArgs/OptReturn in the same order.","Reorder the function's parameters to match the signature's optional model ordering."],"exampleFix":"// before\nfunc (fn *doFn) ProcessElement(ctx context.Context, evt T, emit func(T), side SideIn) // 'side' not in OptArgs\n// after\nfunc (fn *doFn) ProcessElement(ctx context.Context, evt T, emit func(T))","handlingStrategy":"validation","validationCode":"for i, opt := range fnOptionalParams(fn) {\n    if i >= len(sig.OptArgs) || !matchesModel(opt, sig.OptArgs[i]) {\n        return fmt.Errorf(\"optional param %v not offered by sig %v\", opt, sig)\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Match optional parameters (context, emitters, side inputs) to the exact order offered by the Signature.","Remove optional parameters not present in the Signature.","Copy optional parameter patterns from framework examples."],"tags":["go","beam","signature-validation","reflection"],"backgroundTag":"invalid-argument-value","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"}