{"record":{"id":"d8e2e781e173afb9","repo":"vitessio/vitess","slug":"keyspace-s-doesn-t-exist-check-if-the-keyspace","errorCode":null,"errorMessage":"keyspace(%s) doesn't exist, check if the keyspace is initialized","messagePattern":"keyspace\\((.+?)\\) doesn't exist, check if the keyspace is initialized","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/vtctl/vtctl.go","lineNumber":3444,"sourceCode":"\t}\n\tsort.Strings(vdxNames)\n\tfor _, name := range vdxNames {\n\t\tvdx := ksVs.Vindexes[name]\n\t\tif val, ok := vdx.(vindexes.ParamValidating); ok {\n\t\t\tfor _, param := range val.UnknownParams() {\n\t\t\t\twr.Logger().Warningf(\"Unknown parameter in vindex %s: %s\", name, param)\n\t\t\t}\n\t\t}\n\t}\n\n\tif *dryRun {\n\t\twr.Logger().Printf(\"Dry run: Skipping update of VSchema\\n\")\n\t\treturn nil\n\t}\n\n\tif _, err := wr.TopoServer().GetKeyspace(ctx, keyspace); err != nil {\n\t\tif strings.Contains(err.Error(), \"node doesn't exist\") {\n\t\t\treturn fmt.Errorf(\"keyspace(%s) doesn't exist, check if the keyspace is initialized\", keyspace)\n\t\t}\n\t\treturn err\n\t}\n\n\tif _, err := vindexes.BuildKeyspace(ksvs.Keyspace, wr.SQLParser()); err != nil {\n\t\treturn err\n\t}\n\n\tif err := wr.TopoServer().SaveVSchema(ctx, ksvs); err != nil {\n\t\treturn err\n\t}\n\n\tif *skipRebuild {\n\t\twr.Logger().Warningf(\"Skipping rebuild of SrvVSchema, will need to run RebuildVSchemaGraph for changes to take effect\")\n\t\treturn nil\n\t}\n\treturn wr.TopoServer().RebuildSrvVSchema(ctx, cells)\n}","sourceCodeStart":3426,"sourceCodeEnd":3462,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/vtctl/vtctl.go#L3426-L3462","documentation":"Before updating the VSchema, the command checks that the target keyspace exists in the topo via GetKeyspace. If the topo reports the node does not exist ('node doesn't exist'), this friendlier error is returned. It prevents creating VSchema entries for keyspaces that were never initialized.","triggerScenarios":"Running `vtctldclient ApplyVSchema`/RebuildKeyspace against a keyspace name that has no keyspace record in the topo server.","commonSituations":"Typo in keyspace name; keyspace created only implicitly by tablets before any GetKeyspace/init; fresh cluster where no keyspace object was created yet; wrong topo environment (staging vs prod).","solutions":["Verify the keyspace exists: `vtctldclient GetKeyspace <name>` or `vtctl GetTablets`","Initialize the keyspace first (create tablets/etcd record) or use `vtctldclient CreateKeyspace`","Check you are pointed at the correct topo server/cell (--topo flags, VTCTLD_TOPO_INFO)"],"exampleFix":"// before\nvtctldclient ApplyVSchema --vschema vs.json commerce\n// after\nvtctldclient GetKeyspace commerce  # confirm exists first\nvtctldclient ApplyVSchema --vschema vs.json commerce","handlingStrategy":"validation","validationCode":"_, err := wr.TopoServer().GetKeyspace(ctx, keyspace)\nif err != nil {\n\treturn fmt.Errorf(\"keyspace %s must exist before ApplyVSchema: %v\", keyspace, err)\n}","typeGuard":null,"tryCatchPattern":"if err := client.ApplyVSchema(ctx, ks, vs); err != nil {\n\tif strings.Contains(err.Error(), \"doesn't exist\") {\n\t\treturn fmt.Errorf(\"initialize keyspace %s first\", ks)\n\t}\n\treturn err\n}","preventionTips":["Always run GetKeyspace to confirm existence before applying vschema changes","Verify topo server endpoints/environment before operations","Standardize keyspace names in config to avoid typos"],"tags":["vtctl","topo","keyspace","go"],"backgroundTag":"keyspace-does-not-exist","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}