{"record":{"id":"63e88bb5e14768aa","repo":"vitessio/vitess","slug":"invalid-init-tablet-type-v-can-only-be-replica","errorCode":null,"errorMessage":"invalid init-tablet-type %v; can only be REPLICA, RDONLY, EXPERIMENTAL or SPARE","messagePattern":"invalid init-tablet-type (.+?); can only be REPLICA, RDONLY, EXPERIMENTAL or SPARE","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/vttablet/tabletmanager/tm_init.go","lineNumber":271,"sourceCode":"\n\tif initKeyspace == \"\" || initShard == \"\" {\n\t\treturn nil, errors.New(\"init-keyspace and init-shard must be specified\")\n\t}\n\n\t// parse and validate shard name\n\tshard, keyRange, err := topo.ValidateShardName(initShard)\n\tif err != nil {\n\t\treturn nil, vterrors.Wrapf(err, \"cannot validate shard name %v\", initShard)\n\t}\n\n\ttabletType, err := topoproto.ParseTabletType(initTabletType)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tswitch tabletType {\n\tcase topodatapb.TabletType_SPARE, topodatapb.TabletType_REPLICA, topodatapb.TabletType_RDONLY, topodatapb.TabletType_EXPERIMENTAL:\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"invalid init-tablet-type %v; can only be REPLICA, RDONLY, EXPERIMENTAL or SPARE\", tabletType)\n\t}\n\n\tbuildTags, err := getBuildTags(servenv.AppVersion.ToStringMap(), skipBuildInfoTags)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar charset collations.ID\n\tif db != nil && db.Charset != \"\" {\n\t\tcharset, err = collationEnv.ParseConnectionCharset(db.Charset)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t} else {\n\t\tcharset = collationEnv.DefaultConnectionCharset()\n\t}\n\n\treturn &topodatapb.Tablet{","sourceCodeStart":253,"sourceCodeEnd":289,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/vttablet/tabletmanager/tm_init.go#L253-L289","documentation":"BuildTabletFromInput validates the --init_tablet_type flag when vttablet initializes a new tablet record. Only REPLICA, RDONLY, EXPERIMENTAL or SPARE are allowed; PRIMARY-like or invalid values are rejected because initial type must not be a serving-primary type.","triggerScenarios":"Starting vttablet with --init_tablet_type set to something other than REPLICA, RDONLY, EXPERIMENTAL or SPARE (e.g. PRIMARY, MASTER, or a typo).","commonSituations":"Copy-paste of old configs using the removed MASTER value, operators trying to init a tablet as PRIMARY directly, typos in deployment manifests.","solutions":["Set --init_tablet_type=REPLICA (the most common choice) or RDONLY/SPARE as appropriate","Promote to primary afterwards via InitPrimary/PlannedRecoveryType instead of initializing as primary","Fix any leftover 'MASTER' values in manifests — use REPLICA and let topology handle promotion","Validate the flag value before deployment to catch typos"],"exampleFix":"// before\nvttablet --init_tablet_type=MASTER ...\n// after\nvttablet --init_tablet_type=REPLICA ...","handlingStrategy":"validation","validationCode":"var validInitTypes = map[string]bool{\"REPLICA\": true, \"RDONLY\": true, \"EXPERIMENTAL\": true, \"SPARE\": true}\nif !validInitTypes[strings.ToUpper(initTabletType)] {\n    return fmt.Errorf(\"--init_tablet_type must be REPLICA, RDONLY, EXPERIMENTAL or SPARE, got %q\", initTabletType)\n}","typeGuard":null,"tryCatchPattern":"if err := startVttablet(flags); err != nil && strings.Contains(err.Error(), \"invalid init-tablet-type\") {\n    // fix the flag in the deployment manifest and restart\n}","preventionTips":["Lint deployment manifests against valid flag values","Never use MASTER/PRIMARY for --init_tablet_type; promote later instead","Default to REPLICA unless a batch/serving tier is intended","Validate flags in CI config tests before rollout"],"tags":["vttablet","init-tablet-type","configuration","cli-flag"],"backgroundTag":"invalid-init-tablet-type","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}