t8y2/dbx · error

%s must be a positive integer

Error message

%s must be a positive integer

What it means

positiveInt is a helper used by parseConnectionConfig for numeric options like fetch_size, connect_retry_max, and connect_timeout_ms. When strconv.Atoi fails or the value is <= 0, it returns '<name> must be a positive integer' naming the offending parameter.

Source

Thrown at agents/drivers/iotdb/driver.go:372

func firstQueryValue(values url.Values, keys ...string) string {
	for _, key := range keys {
		if value := strings.TrimSpace(values.Get(key)); value != "" {
			return value
		}
	}
	return ""
}

func queryBool(values url.Values, keys ...string) bool {
	value := strings.ToLower(firstQueryValue(values, keys...))
	return value == "1" || value == "true" || value == "yes" || value == "on"
}

func positiveInt(value, name string) (int, error) {
	parsed, err := strconv.Atoi(value)
	if err != nil || parsed <= 0 {
		return 0, fmt.Errorf("%s must be a positive integer", name)
	}
	return parsed, nil
}

func parseNodeURLs(value string) []string {
	parts := strings.FieldsFunc(value, func(char rune) bool { return char == ',' || char == ';' })
	result := make([]string, 0, len(parts))
	for _, part := range parts {
		if normalized := strings.TrimSpace(part); normalized != "" {
			result = append(result, normalized)
		}
	}
	return result
}

View on GitHub (pinned to c0390bff16)

Solutions

  1. Set the parameter to a plain positive integer without units, separators, or whitespace.
  2. Remove the parameter to use the built-in default.
  3. Validate numeric values programmatically before building the connection string.
  4. Read the parameter name in the message to identify exactly which key is wrong.

Example fix

// before
"iotdb://root:root@127.0.0.1:6667?fetch_size=100ms"
// after
"iotdb://root:root@127.0.0.1:6667?fetch_size=100"
Defensive patterns

Strategy: validation

Validate before calling

func validPositiveInt(s string) bool {
    n, err := strconv.Atoi(strings.TrimSpace(s))
    return err == nil && n > 0
}
// check before building the connection string:
// validPositiveInt(fetchSizeParam) && validPositiveInt(retryMaxParam) && validPositiveInt(timeoutParam)

Try / catch

cfg, err := parseConnectionConfig(params)
if err != nil && strings.HasSuffix(err.Error(), "must be a positive integer") {
    return fmt.Errorf("fix numeric connection option: %w", err)
}

Prevention

When it happens

Trigger: Passing fetch_size=0, fetch_size=abc, fetch_size= (empty), connect_retry_max=-1, or connect_timeout_ms=100ms in the connection string query or URLParams.

Common situations: Values with units (100ms), thousand separators (1,000), empty strings, or values set from unvalidated environment variables/config files.

Understand the failure class

Background: "must be positive", "Invalid value": how libraries reject invalid parameter values (ValueError, ArgumentError, INVALID_PARAMETER_VALUE) — this error's family across 28 libraries.

Related errors


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