{"record":{"id":"b0514fb3970e9975","repo":"vitessio/vitess","slug":"unknown-keyspace-type-v","errorCode":null,"errorMessage":"unknown keyspace type: %v","messagePattern":"unknown keyspace type: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/topo/topoproto/keyspace.go","lineNumber":31,"sourceCode":"See the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage topoproto\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n\n\ttopodatapb \"vitess.io/vitess/go/vt/proto/topodata\"\n)\n\n// ParseKeyspaceType parses a string into a KeyspaceType.\nfunc ParseKeyspaceType(param string) (topodatapb.KeyspaceType, error) {\n\tvalue, ok := topodatapb.KeyspaceType_value[strings.ToUpper(param)]\n\tif !ok {\n\t\t// default\n\t\treturn topodatapb.KeyspaceType_NORMAL, fmt.Errorf(\"unknown keyspace type: %v\", value)\n\t}\n\treturn topodatapb.KeyspaceType(value), nil\n}\n\n// KeyspaceTypeString returns the string representation of a KeyspaceType.\nfunc KeyspaceTypeString(kt topodatapb.KeyspaceType) string {\n\tstr, ok := topodatapb.KeyspaceType_name[int32(kt)]\n\tif !ok {\n\t\treturn \"UNKNOWN\"\n\t}\n\n\treturn str\n}\n\n// KeyspaceTypeLString returns the lowercased string representation of a\n// KeyspaceType.\nfunc KeyspaceTypeLString(kt topodatapb.KeyspaceType) string {\n\treturn strings.ToLower(KeyspaceTypeString(kt))","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/topo/topoproto/keyspace.go#L13-L49","documentation":"ParseKeyspaceType failed to map the input string to a topodatapb.KeyspaceType enum value. Keyspace types are NORMAL and SNAPSHOT (case-insensitive). Note the error prints the zero enum value rather than the offending input string, which is confusing, but the cause is always a bad input string.","triggerScenarios":"Calling ParseKeyspaceType (via vtctldclient CreateKeyspace's --type flag or Set) with a string that is not NORMAL or SNAPSHOT after uppercasing, e.g. 'normal2', '' (empty), 'dual'.","commonSituations":"Omitting/misspelling the --type value on vtctldclient CreateKeyspace; older docs referencing removed keyspace types; empty flag values defaulting unexpectedly.","solutions":["Pass exactly NORMAL or SNAPSHOT (case-insensitive) as the keyspace type","Remove or fix the empty/misspelled --type value; omit the flag to use the default NORMAL","Check vtctldclient CreateKeyspace --help for accepted values in your version"],"exampleFix":"// before\nvtctldclient CreateKeyspace --type=duel commerce\n// after\nvtctldclient CreateKeyspace --type=SNAPSHOT commerce","handlingStrategy":"validation","validationCode":"switch strings.ToUpper(kt) {\ncase \"NORMAL\", \"SNAPSHOT\":\n    // ok\ndefault:\n    return fmt.Errorf(\"keyspace type must be NORMAL or SNAPSHOT, got %q\", kt)\n}","typeGuard":"func isValidKeyspaceType(s string) bool {\n    _, ok := topodatapb.KeyspaceType_value[strings.ToUpper(s)]\n    return ok\n}","tryCatchPattern":"kt, err := topoproto.ParseKeyspaceType(typeFlag)\nif err != nil {\n    return fmt.Errorf(\"bad --type %q (use NORMAL or SNAPSHOT): %w\", typeFlag, err)\n}","preventionTips":["Only pass NORMAL or SNAPSHOT to keyspace --type flags","Don't pass an empty --type; omit the flag for default NORMAL","Enumerate valid values with topodatapb.KeyspaceType_value when scripting"],"tags":["topo","keyspace","cli-validation"],"backgroundTag":"invalid-enum-value","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}