t8y2/dbx · error

%s must be between 1 and %d bytes

Error message

%s must be between 1 and %d bytes

What it means

After parsing, resolveMaxBufferSize range-checks the value: it must be at least 1 and at most maximumMaxBufferSize bytes. Zero, negative, or oversized values are rejected with this error naming the parameter and the allowed upper bound.

Source

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

	}
	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(
		config.CACertPath,
		config.ClientCertPath,
		config.ClientKeyPath,
		config.CertPath,
		config.KeyPath,

View on GitHub (pinned to c0390bff16)

Solutions

  1. Set max_buffer_size to a positive integer within 1..maximumMaxBufferSize bytes (see error message for the cap).
  2. Remove the parameter entirely to use the driver's default buffer size.
  3. Clamp or validate the configured value in code before building the DSN.
  4. Check for overflow/typo when computing the byte count programmatically.

Example fix

// before
dsn := "zookeeper://zk1:2181?max_buffer_size=0" // meant "default"
// after
dsn := "zookeeper://zk1:2181" // omit param to use defaultMaxBufferSize
Defensive patterns

Strategy: validation

Validate before calling

func clampMaxBufferSize(v int) (int, error) {
	if v <= 0 || v > maximumMaxBufferSize {
		return 0, fmt.Errorf("max_buffer_size=%d out of range 1..%d; unset it to use the default", v, maximumMaxBufferSize)
	}
	return v, nil
}

Try / catch

n, err := strconv.Atoi(cfg.MaxBufferSize)
if err == nil {
	if _, verr := clampMaxBufferSize(n); verr != nil {
		return configError(verr) // fail before connect; retrying won't help
	}
}

Prevention

When it happens

Trigger: Passing max_buffer_size=0, a negative number, or an integer above the driver's maximum allowed buffer size in the connection URL params during connect.

Common situations: Setting 0 thinking it means "unlimited/default", copying an upper bound from another driver that permits larger buffers, or computing the byte value incorrectly and overflowing the cap.

Related errors


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