t8y2/dbx · error

%s must be an integer number of bytes

Error message

%s must be an integer number of bytes

What it means

resolveMaxBufferSize reads the max_buffer_size connection parameter, which must be an integer number of bytes. If the raw string cannot be parsed by strconv.Atoi (non-numeric, unit suffix, empty-but-present, decimals), the driver returns this error before any connection is attempted.

Source

Thrown at agents/drivers/zookeeper/connection.go:471

	if strings.TrimSpace(config.AuthScheme) != "" {
		return strings.ToLower(strings.TrimSpace(config.AuthScheme))
	}
	if configured := strings.TrimSpace(connectionURLParams(config).Get("auth_scheme")); configured != "" {
		return strings.ToLower(configured)
	}
	return defaultAuthScheme
}

func resolveMaxBufferSize(config connectionConfig) (int, error) {
	configured := config.MaxBufferSize
	if configured == nil {
		value := strings.TrimSpace(connectionURLParams(config).Get(maxBufferSizeParam))
		if value == "" {
			return defaultMaxBufferSize, nil
		}
		parsed, err := strconv.Atoi(value)
		if err != nil {
			return 0, fmt.Errorf("%s must be an integer number of bytes", maxBufferSizeParam)
		}
		configured = &parsed
	}
	if *configured <= 0 || *configured > maximumMaxBufferSize {
		return 0, fmt.Errorf("%s must be between 1 and %d bytes", maxBufferSizeParam, maximumMaxBufferSize)
	}
	return *configured, nil
}

func connectionURLParams(config connectionConfig) url.Values {
	params := strings.TrimPrefix(strings.TrimSpace(config.URLParams), "?")
	params = strings.ReplaceAll(params, ";", "&")
	parsed, _ := url.ParseQuery(params)
	return parsed
}

func hasTLSOptions(config connectionConfig) bool {
	return config.SSL || firstNonBlank(

View on GitHub (pinned to c0390bff16)

Solutions

  1. Set max_buffer_size to a plain integer of bytes, e.g. 4194304 instead of "4mb".
  2. Strip units/decimals from the value before saving the connection config.
  3. Convert your desired size: megabytes × 1048576.
  4. Leave the parameter unset to use the driver default.

Example fix

// before
dsn := "zookeeper://zk1:2181?max_buffer_size=4mb"
// after
dsn := "zookeeper://zk1:2181?max_buffer_size=4194304"
Defensive patterns

Strategy: validation

Validate before calling

func validMaxBufferSize(v string) error {
	v = strings.TrimSpace(v)
	if v == "" {
		return nil
	}
	if _, err := strconv.Atoi(v); err != nil {
		return fmt.Errorf("max_buffer_size must be plain integer bytes, got %q", v)
	}
	return nil
}

Try / catch

if err := validMaxBufferSize(cfg.MaxBufferSize); err != nil {
	// reject at config-load time, not at connect time
	return cfgLoadFail(err)
}

Prevention

When it happens

Trigger: Passing max_buffer_size values like "4mb", "4 MB", "4096.0", or other non-integer text in the connection URL params when opening a client.

Common situations: Users writing sizes with byte-size suffixes out of habit (as other drivers accept), or quoting/whitespace/decimal formats that Atoi rejects.

Related errors


AI-assisted analysis of t8y2/dbx@c0390bff16 (2026-09-05). Data as JSON: /api/errors/3fd398bf029deeae. Report an issue: GitHub.