{"record":{"id":"7c7cf05906751cf6","repo":"vitessio/vitess","slug":"no-shards-in-keyspace-v","errorCode":null,"errorMessage":"no shards in keyspace %v","messagePattern":"no shards in keyspace (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/wrangler/permissions.go","lineNumber":111,"sourceCode":"\twg.Wait()\n\tif er.HasErrors() {\n\t\treturn fmt.Errorf(\"permissions diffs: %v\", er.Error().Error())\n\t}\n\treturn nil\n}\n\n// ValidatePermissionsKeyspace validates all the permissions are the same\n// in a keyspace\nfunc (wr *Wrangler) ValidatePermissionsKeyspace(ctx context.Context, keyspace string) error {\n\t// find all the shards\n\tshards, err := wr.ts.GetShardNames(ctx, keyspace)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// corner cases\n\tif len(shards) == 0 {\n\t\treturn fmt.Errorf(\"no shards in keyspace %v\", keyspace)\n\t}\n\tsort.Strings(shards)\n\tif len(shards) == 1 {\n\t\treturn wr.ValidatePermissionsShard(ctx, keyspace, shards[0])\n\t}\n\n\t// find the reference permissions using the first shard's primary\n\tsi, err := wr.ts.GetShard(ctx, keyspace, shards[0])\n\tif err != nil {\n\t\treturn err\n\t}\n\tif !si.HasPrimary() {\n\t\treturn fmt.Errorf(\"no primary in shard %v/%v\", keyspace, shards[0])\n\t}\n\treferenceAlias := si.PrimaryAlias\n\tlog.Info(fmt.Sprintf(\"Gathering permissions for reference primary %v\", topoproto.TabletAliasString(referenceAlias)))\n\treferencePermissions, err := wr.GetPermissions(ctx, si.PrimaryAlias)\n\tif err != nil {","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/wrangler/permissions.go#L93-L129","documentation":"ValidatePermissionsKeyspace fetches the shard list for the keyspace and fails immediately if the keyspace has no shards at all, since there is nothing to validate. It is a guard against operating on an empty or nonexistent keyspace.","triggerScenarios":"Calling `vtctlclient ValidatePermissionsKeyspace <keyspace>` where topo list of shards returns zero entries — either the keyspace name is mistyped or the keyspace was created but never sharded/assigned tablets.","commonSituations":"Typo in the keyspace name on the command line; keyspace created in the topo but shards not yet created (fresh setup, aborted init); keyspace was emptied after a full reshard/migration left it pending teardown.","solutions":["Check the exact keyspace name with `vtctlclient GetKeyspaces` or `vtctlclient GetKeyspace <keyspace>`.","List shards with `vtctlclient ListShards <keyspace>`; if empty, verify you meant a different keyspace.","If the keyspace is genuinely empty and leftover, remove it (`vtctlclient DeleteKeyspace`) or create/populate shards before validating.","If tablets exist but shards are missing in the topo, repair topology registration."],"exampleFix":"// before\nwr.ValidatePermissionsKeyspace(ctx, \"commercee\") // typo\n// after\nwr.ValidatePermissionsKeyspace(ctx, \"commerce\")","handlingStrategy":"validation","validationCode":"shards, err := ts.GetShardNames(ctx, keyspace)\nif err != nil { return err }\nif len(shards) == 0 {\n    return vterrors.Errorf(vtrpcpb.Code_FAILED_PRECONDITION, \"keyspace %s has no shards; check keyspace name\", keyspace)\n}","typeGuard":"func keyspaceHasShards(shards []string) bool { return len(shards) > 0 }","tryCatchPattern":null,"preventionTips":["Verify keyspace spelling with `vtctlclient GetKeyspaces` before running validation commands","Only run validation against keyspaces created via vtctld/upstream tooling so shard records exist","Clean up empty leftover keyspaces after migrations"],"tags":["keyspace","validation","topology","vtctl"],"backgroundTag":"empty-keyspace","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}