bytebase/bytebase · error

failed to convert chunk-size %q to int

Error message

failed to convert chunk-size %q to int

What it means

GetUserFlags parses the chunk-size ghost flag with strconv.ParseInt(v, 10, 64). Any value that is not a valid base-10 integer (letters, units like "10k", empty string) produces this wrapped error. The value must be a plain integer copy chunk size in rows.

Source

Thrown at backend/component/ghost/config.go:128

		return f, nil
	}

	for k := range flags {
		if !knownKeys[k] {
			return nil, errors.Errorf("unsupported flag: %s", k)
		}
	}

	if v, ok := flags["max-load"]; ok {
		if _, err := ghostbase.ParseLoadMap(v); err != nil {
			return nil, errors.Wrapf(err, "failed to parse max-load %q", v)
		}
		f.maxLoad = &v
	}
	if v, ok := flags["chunk-size"]; ok {
		chunkSize, err := strconv.ParseInt(v, 10, 64)
		if err != nil {
			return nil, errors.Wrapf(err, "failed to convert chunk-size %q to int", v)
		}
		f.chunkSize = &chunkSize
	}
	if v, ok := flags["dml-batch-size"]; ok {
		dmlBatchSize, err := strconv.ParseInt(v, 10, 64)
		if err != nil {
			return nil, errors.Wrapf(err, "failed to convert dml-batch-size %q to int", v)
		}
		f.dmlBatchSize = &dmlBatchSize
	}
	if v, ok := flags["default-retries"]; ok {
		defaultRetries, err := strconv.ParseInt(v, 10, 64)
		if err != nil {
			return nil, errors.Wrapf(err, "failed to convert default-retries %q to int", v)
		}
		f.defaultRetries = &defaultRetries
	}
	if v, ok := flags["cut-over-lock-timeout-seconds"]; ok {

View on GitHub (pinned to 1870550677)

Solutions

  1. Set chunk-size to a plain base-10 integer, e.g. "1000".
  2. Strip whitespace/units from the configured value.
  3. Validate the value with strconv.ParseInt before submitting the config.
  4. Check for hidden characters (quotes, spaces) copied from docs or shell history.

Example fix

// before
flags := map[string]string{"chunk-size": "10k"}
f, err := ghost.GetUserConfigFromFlags(flags) // failed to convert chunk-size "10k" to int
// after
flags := map[string]string{"chunk-size": "10000"}
f, err := ghost.GetUserConfigFromFlags(flags)
Defensive patterns

Strategy: validation

Validate before calling

if v, ok := flags["chunk-size"]; ok {
  if n, err := strconv.ParseInt(strings.TrimSpace(v), 10, 64); err != nil || n <= 0 {
    return fmt.Errorf("chunk-size must be a positive integer, got %q", v)
  }
}

Prevention

When it happens

Trigger: ghostFlags contains "chunk-size" set to a non-numeric string, e.g. "1000rows", "1,000", "", or a float like "10.5".

Common situations: Users adding human-friendly units or thousand separators to the value; copying a flag value with trailing whitespace; configuring via UI free-text field.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


AI-assisted analysis of bytebase/bytebase@1870550677 (2026-09-06). Data as JSON: /api/errors/7838000bbd77ca3a. Report an issue: GitHub.