{"record":{"id":"8e5fc098f096487c","repo":"vitessio/vitess","slug":"tenant-id-is-not-a-valid-int-s","errorCode":null,"errorMessage":"tenant id is not a valid int: %s","messagePattern":"tenant id is not a valid int: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/vtctl/workflow/utils.go","lineNumber":858,"sourceCode":") (*sqlparser.Expr, error) {\n\tif vrOptions.TenantId == \"\" {\n\t\treturn nil, nil\n\t}\n\tif targetVSchema == nil || targetVSchema.MultiTenantSpec == nil {\n\t\treturn nil, errors.New(\"target keyspace not defined, or it does not have multi-tenant spec\")\n\t}\n\ttenantColumnName := targetVSchema.MultiTenantSpec.TenantIdColumnName\n\ttenantColumnType := targetVSchema.MultiTenantSpec.TenantIdColumnType\n\tif tenantColumnName == \"\" {\n\t\treturn nil, errors.New(\"tenant column name not defined in multi-tenant spec\")\n\t}\n\n\tvar tenantId string\n\tswitch tenantColumnType {\n\tcase querypb.Type_INT64:\n\t\t_, err := strconv.Atoi(vrOptions.TenantId)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"tenant id is not a valid int: %s\", vrOptions.TenantId)\n\t\t}\n\t\ttenantId = vrOptions.TenantId\n\tcase querypb.Type_VARCHAR:\n\t\ttenantId = sqltypes.EncodeStringSQL(vrOptions.TenantId)\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"unsupported tenant column type: %s\", tenantColumnType)\n\t}\n\n\tstmt, err := parser.Parse(fmt.Sprintf(\"select * from t where %s = %s\", sqlescape.EscapeID(tenantColumnName), tenantId))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tsel, ok := stmt.(*sqlparser.Select)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"error getting select: %s\", tenantId)\n\t}\n\treturn &sel.Where.Expr, nil\n}","sourceCodeStart":840,"sourceCodeEnd":876,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/vtctl/workflow/utils.go#L840-L876","documentation":"getTenantClause builds a WHERE clause for tenant-filtered queries during multi-tenant MoveTables. If the tenant column is typed INT64, the TenantId from VReplicationOptions must parse as an integer; strconv.Atoi failure triggers this error. It prevents generating an invalid SQL literal (e.g. an unquoted string in an integer comparison).","triggerScenarios":"Running MoveTables with --source-tenant-id (or equivalent VReplicationOptions.TenantId) whose value is non-numeric while the tenant column in the table is an integer type (INT64).","commonSituations":"Tenant IDs stored as integers but operator passed an alphanumeric identifier (e.g. 'TENANT-42'); leading/trailing spaces or a comma-separated list passed instead of one integer; copy-paste from config where tenant keys are strings.","solutions":["Pass a plain integer tenant id (e.g. 42) matching the tenant column's INT64 type.","Strip whitespace, quotes, or extra characters from the tenant id argument.","If tenant ids are genuinely non-numeric, the tenant column should be VARCHAR — verify the column type and use the appropriate value."],"exampleFix":"// before\n--source-tenant-id \"acme-corp\" // tenant column is INT64\n// after\n--source-tenant-id 42","handlingStrategy":"validation","validationCode":"if tenantColumnType == querypb.Type_INT64 {\n\tif _, err := strconv.Atoi(strings.TrimSpace(tenantID)); err != nil {\n\t\treturn fmt.Errorf(\"tenant id %q must be an integer for INT64 tenant column\", tenantID)\n\t}\n}","typeGuard":"func isValidIntTenantID(v string) bool { _, err := strconv.Atoi(strings.TrimSpace(v)); return err == nil }","tryCatchPattern":"clause, err := getTenantClause(...)\nif err != nil {\n\tif strings.Contains(err.Error(), \"tenant id is not a valid int\") {\n\t\treturn fmt.Errorf(\"fix --source-tenant-id: must be a plain integer for this column: %w\", err)\n\t}\n\treturn err\n}","preventionTips":["Confirm the tenant column's type (SHOW CREATE TABLE) before choosing the tenant id format","Trim and quote-strip CLI inputs in wrapper scripts","Validate tenant ids in automation with strconv.Atoi before invoking MoveTables"],"tags":["validation","tenant","movetables","vreplication"],"backgroundTag":"invalid-integer-input","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}