{"record":{"id":"54715f48c2db4064","repo":"apache/beam","slug":"expected-1-option-got-v-v","errorCode":null,"errorMessage":"expected 1 option, got %v: %v","messagePattern":"expected 1 option, got (.+?): (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/runtime/harness/cache_hooks.go","lineNumber":37,"sourceCode":"\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/apache/beam/sdks/v2/go/pkg/beam/core/util/hooks\"\n)\n\nvar (\n\tcacheSize int = 0\n)\n\nfunc init() {\n\thf := func(opts []string) hooks.Hook {\n\t\treturn hooks.Hook{\n\t\t\tInit: func(ctx context.Context) (context.Context, error) {\n\t\t\t\tif len(opts) == 0 {\n\t\t\t\t\treturn ctx, nil\n\t\t\t\t}\n\t\t\t\tif len(opts) > 1 {\n\t\t\t\t\treturn ctx, fmt.Errorf(\"expected 1 option, got %v: %v\", len(opts), opts)\n\t\t\t\t}\n\n\t\t\t\tvar count int\n\t\t\t\t_, err := fmt.Sscan(opts[0], &count)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t\tcacheSize = count\n\t\t\t\treturn ctx, nil\n\t\t\t},\n\t\t}\n\t}\n\thooks.RegisterHook(\"beam:go:hook:sideinputcache:capacity\", hf)\n}\n","sourceCodeStart":19,"sourceCodeEnd":52,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/runtime/harness/cache_hooks.go#L19-L52","documentation":"The cache hooks hook's Init validates the cache hook's options: exactly zero or one option is allowed, where the single option is the cache size. If more than one option is supplied, this error is returned, reporting the count and the raw option values.","triggerScenarios":"Configuring the harness cache hook (via --cache_size style hook options) with more than one comma/semicolon-separated option string so len(opts) > 1, e.g. \"100,debug\".","commonSituations":"Users appending extra arguments to the cache size option in worker harness flags, or copy-pasting hook option strings that include extraneous parameters.","solutions":["Pass exactly one option: the cache entry count, e.g. \"1000\".","Remove any extra comma/space-separated values from the hook option string.","Leave the option empty to use defaults (len(opts)==0 is accepted)."],"exampleFix":"// before\n--cache_size=\"1000,unbounded\"\n// after\n--cache_size=\"1000\"","handlingStrategy":"validation","validationCode":"opts := strings.Split(cacheOpt, \",\")\nif len(opts) > 1 { return fmt.Errorf(\"cache hook takes at most 1 option, got %d\", len(opts)) }\nif len(opts) == 1 { if _, err := strconv.Atoi(opts[0]); err != nil { return err } }","typeGuard":null,"tryCatchPattern":"if err := hook.Init(ctx); err != nil {\n\tlog.Fatalf(\"cache hook option error: %v\", err)\n}","preventionTips":["Pass only the numeric cache size as the hook option.","Never append debug/extra flags to the cache_size option."],"tags":["configuration","hook","argument-count","beam","go"],"backgroundTag":"missing-required-option","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"}