{"record":{"id":"803f90154d852c60","repo":"vitessio/vitess","slug":"invalid-tablet-alias-s-expecting-format-s","errorCode":null,"errorMessage":"invalid tablet alias: '%s', expecting format: '%s'","messagePattern":"invalid tablet alias: '(.+?)', expecting format: '(.+?)'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/topo/topoproto/tablet.go","lineNumber":93,"sourceCode":"\n// TabletAliasString formats a TabletAlias\nfunc TabletAliasString(ta *topodatapb.TabletAlias) string {\n\tif ta == nil {\n\t\treturn \"<nil>\"\n\t}\n\treturn fmt.Sprintf(\"%v-%010d\", ta.Cell, ta.Uid)\n}\n\nconst tabletAliasFormat = \"^(?P<cell>[-_.a-zA-Z0-9]+)-(?P<uid>[0-9]+)$\"\n\nvar tabletAliasRegexp = regexp.MustCompile(tabletAliasFormat)\n\n// ParseTabletAlias returns a TabletAlias for the input string,\n// of the form <cell>-<uid>\nfunc ParseTabletAlias(aliasStr string) (*topodatapb.TabletAlias, error) {\n\tnameParts := tabletAliasRegexp.FindStringSubmatch(aliasStr)\n\tif len(nameParts) != 3 {\n\t\treturn nil, fmt.Errorf(\"invalid tablet alias: '%s', expecting format: '%s'\", aliasStr, tabletAliasFormat)\n\t}\n\tuid, err := ParseUID(nameParts[tabletAliasRegexp.SubexpIndex(\"uid\")])\n\tif err != nil {\n\t\treturn nil, vterrors.Wrapf(err, \"invalid tablet uid in alias '%s'\", aliasStr)\n\t}\n\treturn &topodatapb.TabletAlias{\n\t\tCell: nameParts[tabletAliasRegexp.SubexpIndex(\"cell\")],\n\t\tUid:  uid,\n\t}, nil\n}\n\n// ParseTabletSet returns a set of tablets based on a provided comma separated list of tablets.\nfunc ParseTabletSet(tabletListStr string) sets.Set[string] {\n\tset := sets.New[string]()\n\tif tabletListStr == \"\" {\n\t\treturn set\n\t}\n\tlist := strings.Split(tabletListStr, \",\")","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/topo/topoproto/tablet.go#L75-L111","documentation":"ParseTabletAlias expects an alias of the form <cell>-<uid> (e.g. zone1-100), validated by a regular expression. The input did not match the expected pattern, so no alias could be built. Note that a syntactically matching alias with a bad UID raises a different wrapped error.","triggerScenarios":"Passing a string without the cell-uid form to ParseTabletAlias — e.g. '100', 'zone1_100', 'zone1-100-0', empty string — via commands like Backup, RestoreFromBackup, ExecuteFetchAsDBA, GetPermissions, or TabletAliasesFromPosArgs.","commonSituations":"Using underscore instead of hyphen; omitting the cell prefix; passing a hostname or IP; trailing whitespace or CR from copied config values; case where the cell name contains characters the regexp disallows.","solutions":["Use the format cell-uid, e.g. zone1-100, matching the alias shown by vtctldclient GetTablets","Strip whitespace/newlines from the value (shell quoting or tr -d '\\r')","Use the correct separator: hyphen between cell and UID, not underscore or dot"],"exampleFix":"// before\nvtctldclient GetPermissions zone1_100\n// after\nvtctldclient GetPermissions zone1-100","handlingStrategy":"validation","validationCode":"if !regexp.MustCompile(`^[a-zA-Z0-9][a-zA-Z0-9.-]*-[0-9]+$`).MatchString(alias) {\n    return fmt.Errorf(\"alias %q must be <cell>-<uid>\", alias)\n}","typeGuard":"func looksLikeTabletAlias(s string) bool {\n    return regexp.MustCompile(`^[^-]+-[0-9]+$`).MatchString(strings.TrimSpace(s))\n}","tryCatchPattern":"alias, err := topoproto.ParseTabletAlias(input)\nif err != nil {\n    return fmt.Errorf(\"bad tablet alias %q: %w\", input, err)\n}","preventionTips":["Use cell-uid exactly as printed by vtctldclient GetTablets","Trim whitespace and CR/LF from values read from files/pipes","Use hyphen between cell and UID, never underscore","Take aliases from topo queries rather than hand-typing"],"tags":["topo","tablet-alias","cli-validation"],"backgroundTag":"invalid-tablet-alias-format","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}