{"record":{"id":"65717208fb5d50b6","repo":"vitessio/vitess","slug":"getvschema-keyspace-s-w","errorCode":null,"errorMessage":"GetVSchema(keyspace = %s): %w","messagePattern":"GetVSchema\\(keyspace = (.+?)\\): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/vtadmin/api.go","lineNumber":1672,"sourceCode":"\t\t\t}\n\n\t\t\tgetKeyspacesSpan.Finish()\n\n\t\t\tvar (\n\t\t\t\tclusterM        sync.Mutex\n\t\t\t\tclusterWG       sync.WaitGroup\n\t\t\t\tclusterRec      concurrency.AllErrorRecorder\n\t\t\t\tclusterVSchemas = make([]*vtadminpb.VSchema, 0, len(keyspaces.Keyspaces))\n\t\t\t)\n\n\t\t\tfor _, keyspace := range keyspaces.Keyspaces {\n\t\t\t\tclusterWG.Add(1)\n\n\t\t\t\tgo func(keyspace *vtctldatapb.Keyspace) {\n\t\t\t\t\tdefer clusterWG.Done()\n\t\t\t\t\tvschema, err := c.GetVSchema(ctx, keyspace.Name)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tclusterRec.RecordError(fmt.Errorf(\"GetVSchema(keyspace = %s): %w\", keyspace.Name, err))\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\n\t\t\t\t\tclusterM.Lock()\n\t\t\t\t\tclusterVSchemas = append(clusterVSchemas, vschema)\n\t\t\t\t\tclusterM.Unlock()\n\t\t\t\t}(keyspace)\n\t\t\t}\n\n\t\t\tclusterWG.Wait()\n\n\t\t\tif clusterRec.HasErrors() {\n\t\t\t\trec.RecordError(fmt.Errorf(\"GetVSchemas(cluster = %s): %w\", c.ID, clusterRec.Error()))\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tm.Lock()\n\t\t\tvschemas = append(vschemas, clusterVSchemas...)","sourceCodeStart":1654,"sourceCodeEnd":1690,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/vtadmin/api.go#L1654-L1690","documentation":"For each keyspace in a cluster, GetVSchemas calls c.GetVSchema to load its vschema; a per-keyspace failure is recorded with this wrapper naming the keyspace and embedding the cause. The errors accumulate in a per-cluster recorder and ultimately fail that cluster's vschema aggregation.","triggerScenarios":"Calling GetVSchemas when c.GetVSchema fails for a keyspace: the vschema is invalid JSON in the topo, the topo read fails, or vtctld returns an error for that keyspace.","commonSituations":"Hand-edited vschema JSON with syntax errors in the topo; keyspace deleted between GetKeyspaces and GetVSchema; topo connectivity problems; permission issues reading topo keys.","solutions":["Read the wrapped message to find the exact keyspace and cause","Validate the vschema JSON for that keyspace (vtctldclient GetVSchema / jq .)","Re-apply a valid vschema with vtctldclient ApplyVSchema if it is corrupt","Check topo health if the read itself failed"],"exampleFix":"// before\nvschema, err := c.GetVSchema(ctx, keyspace.Name)\nif err != nil {\n\tclusterRec.RecordError(fmt.Errorf(\"GetVSchema(keyspace = %s): %w\", keyspace.Name, err))\n\treturn\n}\n// after: fix invalid vschema JSON in topo, then same call succeeds\nvschema, err := c.GetVSchema(ctx, keyspace.Name)\nif err != nil {\n\tclusterRec.RecordError(fmt.Errorf(\"GetVSchema(keyspace = %s): %w\", keyspace.Name, err))\n\treturn\n}","handlingStrategy":"validation","validationCode":"// validate vschema JSON before relying on aggregation\nraw, err := vtctldClient.GetVSchema(ctx, &vtctldatapb.GetVSchemaRequest{Keyspace: ks})\nif err != nil || raw.VSchema == nil {\n\tlog.Printf(\"keyspace %s vschema unreadable: %v\", ks, err)\n}","typeGuard":"func vschemaErrors(clusterRec concurrency.AllErrorRecorder) bool { return clusterRec.HasErrors() }","tryCatchPattern":"resp, err := client.GetVSchemas(ctx, req)\nif err != nil {\n\tif strings.Contains(err.Error(), \"GetVSchema(keyspace = \") {\n\t\t// extract keyspace; validate/fix its vschema in topo\n\t}\n\treturn err\n}","preventionTips":["Lint vschema JSON before applying (vtctldclient ApplyVSchema)","Validate vschemas in CI after edits","Avoid hand-editing topo keys directly","Monitor topo read errors"],"tags":["vtadmin","vschema","keyspace","topology"],"backgroundTag":"invalid-vschema","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}