{"record":{"id":"2e5211105354af86","repo":"vitessio/vitess","slug":"flagutil-newoptionalflag-requires-a-non-nil-parse","errorCode":null,"errorMessage":"flagutil: NewOptionalFlag requires a non-nil parse function","messagePattern":"flagutil: NewOptionalFlag requires a non-nil parse function","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"go/flagutil/optional.go","lineNumber":112,"sourceCode":"\nfunc (o *OptionalString) Type() string { return \"string\" }\n\nfunc (o *OptionalString) IsSet() bool { return o.set }\n\n// Get returns the underlying string value.\nfunc (o *OptionalString) Get() string { return o.val }\n\nvar (\n\t_ OptionalFlag = (*OptionalFloat64)(nil)\n\t_ OptionalFlag = (*OptionalString)(nil)\n)\n\n// NewOptionalFlag returns a *OptionalFlagValue[T] with the given default value,\n// pflag type name, parse function, and stringer.\n// It returns an error if parse is nil, since a flag without a parse function cannot be set.\nfunc NewOptionalFlag[T any](defaultVal T, typeName string, parse func(string) (T, error), stringer func(T) string) (*OptionalFlagValue[T], error) {\n\tif parse == nil {\n\t\treturn nil, errors.New(\"flagutil: NewOptionalFlag requires a non-nil parse function\")\n\t}\n\treturn &OptionalFlagValue[T]{\n\t\tval:      defaultVal,\n\t\ttypeName: typeName,\n\t\tparse:    parse,\n\t\tstringer: stringer,\n\t}, nil\n}\n\nfunc (f *OptionalFlagValue[T]) Set(arg string) error {\n\tif f.parse == nil {\n\t\treturn errors.New(\"flagutil: OptionalFlagValue has no parse function; use a constructor such as NewOptionalFlag\")\n\t}\n\n\tv, err := f.parse(arg)\n\tif err != nil {\n\t\treturn err\n\t}","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/flagutil/optional.go#L94-L130","documentation":"Cluster.GetVSchemas takes a single topoReadPool slot for the whole multi-cell GetSrvVSchemas call. If acquisition fails (ctx cancelled/timed out waiting), the entire cluster vschema fetch fails with this wrapped error naming the cluster and requested cells.","triggerScenarios":"Calling Cluster.GetVSchemas when the pool has no free slot and the request context is cancelled before Acquire succeeds.","commonSituations":"Bursts of vschema requests in the vtadmin UI; saturated topoReadPool from parallel fan-out calls; slow topo backends.","solutions":["Retry the request","Increase the topo read pool capacity or reduce concurrent callers","Check topo server health/latency (etcd/zk) that lengthens slot hold times"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"vs, err := cluster.GetVSchemas(ctx, cells)\nif err != nil {\n\tif errors.Is(err, context.Canceled) || errors.Is(err, context.DeadlineExceeded) {\n\t\t// wait and retry once with a fresh context\n\t}\n}","preventionTips":["Limit concurrent cluster-wide vschema fetches","Raise topoReadPool size for large clusters","Track pool wait times via tracing spans"],"tags":["vtadmin","topology","concurrency","vschema"],"backgroundTag":"semaphore-acquire-timeout","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}