{"record":{"id":"78550440ad475449","repo":"vitessio/vitess","slug":"unknown-keyspace-type-v-785504","errorCode":null,"errorMessage":"unknown keyspace type %v","messagePattern":"unknown keyspace type (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/vtctl/grpcvtctldserver/server.go","lineNumber":945,"sourceCode":"\tspan.Annotate(\"durability_policy\", req.DurabilityPolicy)\n\n\tswitch req.Type {\n\tcase topodatapb.KeyspaceType_NORMAL:\n\tcase topodatapb.KeyspaceType_SNAPSHOT:\n\t\tif req.BaseKeyspace == \"\" {\n\t\t\terr = errors.New(\"BaseKeyspace is required for SNAPSHOT keyspaces\")\n\t\t\treturn nil, err\n\t\t}\n\n\t\tif req.SnapshotTime == nil {\n\t\t\terr = errors.New(\"SnapshotTime is required for SNAPSHOT keyspaces\")\n\t\t\treturn nil, err\n\t\t}\n\n\t\tspan.Annotate(\"base_keyspace\", req.BaseKeyspace)\n\t\tspan.Annotate(\"snapshot_time\", protoutil.TimeFromProto(req.SnapshotTime).String())\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"unknown keyspace type %v\", req.Type)\n\t}\n\n\tki := &topodatapb.Keyspace{\n\t\tKeyspaceType:     req.Type,\n\t\tBaseKeyspace:     req.BaseKeyspace,\n\t\tSnapshotTime:     req.SnapshotTime,\n\t\tDurabilityPolicy: req.DurabilityPolicy,\n\t\tSidecarDbName:    req.SidecarDbName,\n\t}\n\n\terr = s.ts.CreateKeyspace(ctx, req.Name, ki)\n\tif req.Force && topo.IsErrType(err, topo.NodeExists) {\n\t\tlog.Info(fmt.Sprintf(\"keyspace %v already exists (ignoring error with Force=true)\", req.Name))\n\t\terr = nil\n\n\t\t// Get the actual keyspace out of the topo; it may differ in structure,\n\t\t// and we want to return the authoritative version as the \"created\" one\n\t\t// to the client.","sourceCodeStart":927,"sourceCodeEnd":963,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/vtctl/grpcvtctldserver/server.go#L927-L963","documentation":"CreateKeyspace validates that req.Type is one of the supported KeyspaceType values (NORMAL or SNAPSHOT). Any other protobuf enum value falls into the switch's default branch and is rejected with this fmt.Errorf before any topology writes occur.","triggerScenarios":"Calling CreateKeyspace with req.Type set to an invalid/undefined topodatapb.KeyspaceType value (including the zero value if it is not handled, or a corrupt/garbage enum from a hand-built request).","commonSituations":"Hand-crafted RPC requests or generated clients using wrong enum values; copy-paste from code constructing a SNAPSHOT keyspace; protobuf enum deserialization from an incompatible client version.","solutions":["Set req.Type to topodatapb.KeyspaceType_NORMAL (the default for ordinary keyspaces)","Only use topodatapb.KeyspaceType_SNAPSHOT when creating snapshot keyspaces with BaseKeyspace and SnapshotTime set","Ensure the client library and server use the same vitess proto version"],"exampleFix":"// before\nreq.Type = topodatapb.KeyspaceType(7)\n// after\nreq.Type = topodatapb.KeyspaceType_NORMAL","handlingStrategy":"validation","validationCode":"if req.Type != topodatapb.KeyspaceType_NORMAL && req.Type != topodatapb.KeyspaceType_SNAPSHOT {\n    return fmt.Errorf(\"unsupported keyspace type %v\", req.Type)\n}","typeGuard":"func validKeyspaceType(t topodatapb.KeyspaceType) bool {\n    return t == topodatapb.KeyspaceType_NORMAL || t == topodatapb.KeyspaceType_SNAPSHOT\n}","tryCatchPattern":"_, err := client.CreateKeyspace(ctx, req)\nif err != nil && strings.Contains(err.Error(), \"unknown keyspace type\") {\n    req.Type = topodatapb.KeyspaceType_NORMAL // retry with default\n}","preventionTips":["Always set Type explicitly to NORMAL unless creating snapshots","Only build requests with generated proto enums, never raw ints","Keep client proto definitions in sync with the server version","For SNAPSHOT, also set BaseKeyspace and SnapshotTime"],"tags":["vitess","keyspace","validation","enum"],"backgroundTag":"invalid-keyspace-type","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}