vitessio/vitess · error

value %s is not a valid int

Error message

value %s is not a valid int

What it means

validateTenantId pre-validates a tenant value for moveTablesCreate. When the tenant column data type is INT64, the supplied value string must parse with strconv.Atoi; otherwise this error is returned before any workflow is created. It is the create-time counterpart of the getTenantClause check, failing fast on bad input.

Source

Thrown at go/vt/vtctl/workflow/utils.go:919

	}
	err := update()
	if err == nil {
		return nil
	}
	// If we were racing with another caller to create the initial routing rules, then
	// we can immediately retry the operation.
	if !topo.IsErrType(err, topo.NodeExists) {
		return err
	}
	return update()
}

func validateTenantId(dataType querypb.Type, value string) error {
	switch dataType {
	case querypb.Type_INT64:
		_, err := strconv.Atoi(value)
		if err != nil {
			return fmt.Errorf("value %s is not a valid int", value)
		}
	case querypb.Type_VARCHAR:
	// no validation needed
	default:
		return fmt.Errorf("unsupported data type: %s", dataType)
	}
	return nil
}

func updateKeyspaceRoutingState(ctx context.Context, ts *topo.Server, sourceKeyspace, targetKeyspace string, state *State) error {
	// For multi-tenant migrations, we only support switching traffic to all cells at once.
	cells, err := ts.GetCellInfoNames(ctx)
	if err != nil {
		return err
	}

	rules, err := topotools.GetKeyspaceRoutingRules(ctx, ts)
	if err != nil {

View on GitHub (pinned to 01a25a7d17)

Solutions

  1. Supply the tenant id as a plain base-10 integer, e.g. --source-tenant-id 42.
  2. Trim whitespace/quotes from the value before passing it.
  3. If tenant ids are non-numeric, ensure the tenant column is VARCHAR, which skips this validation.

Example fix

// before
vtctldclient MoveTables --workflow w --source-tenant-id "4.5" Create ...
// after
vtctldclient MoveTables --workflow w --source-tenant-id 4 Create ...
Defensive patterns

Strategy: validation

Validate before calling

if dataType == querypb.Type_INT64 {
	if _, err := strconv.Atoi(value); err != nil {
		return fmt.Errorf("--source-tenant-id must be a plain integer, got %q", value)
	}
}

Type guard

func isPlainInt(s string) bool { _, err := strconv.Atoi(s); return err == nil }

Try / catch

if err := validateTenantId(dataType, value); err != nil {
	if strings.Contains(err.Error(), "not a valid int") {
		return fmt.Errorf("bad tenant id for INT64 column: %w", err)
	}
	return err
}

Prevention

When it happens

Trigger: Calling MoveTables Create (vtctldclient MoveTables Create) with --source-tenant-id that is not a valid integer while the tenant column is INT64.

Common situations: Passing a string tenant identifier (e.g. 'emea'), a decimal ('4.2'), a comma-separated list, or a value with quotes/spaces for an integer tenant column.

Related errors


AI-assisted analysis of vitessio/vitess@01a25a7d17 (2026-09-01). Data as JSON: /api/errors/5f1bca0f809e158d. Report an issue: GitHub.