weaviate/weaviate · error

parse LAZY_LOAD_SHARD_COUNT_THRESHOLD as int: %w

Error message

parse LAZY_LOAD_SHARD_COUNT_THRESHOLD as int: %w

What it means

FromEnv parses LAZY_LOAD_SHARD_COUNT_THRESHOLD with strconv.Atoi to configure the shard count at which lazy shard loading auto-detection kicks in. If the value is not a plain base-10 integer, the Atoi error is wrapped as "parse LAZY_LOAD_SHARD_COUNT_THRESHOLD as int: %w" and config loading aborts.

Source

Thrown at usecases/config/environment.go:162

		config.TrackVectorDimensionsInterval = DefaultTrackVectorDimensionsInterval
	}

	if entcfg.Enabled(os.Getenv("REINDEX_VECTOR_DIMENSIONS_AT_STARTUP")) {
		config.ReindexVectorDimensionsAtStartup = true
	}

	if entcfg.Enabled(os.Getenv("DISABLE_LAZY_LOAD_SHARDS")) {
		logrus.Warn("DISABLE_LAZY_LOAD_SHARDS is deprecated and will be removed in a future version. Use LAZY_LOAD_SHARD_COUNT_THRESHOLD instead to configure dynamic lazy load shards if needed, otherwise weaviate will decide based on the shard count and size thresholds.")
		v := false
		config.EnableLazyLoadShards = &v
	}

	// Lazy load shard count threshold for auto-detection
	// Determines at what shard count auto-detection enables lazy loading
	if v := os.Getenv("LAZY_LOAD_SHARD_COUNT_THRESHOLD"); v != "" {
		asInt, err := strconv.Atoi(v)
		if err != nil {
			return fmt.Errorf("parse LAZY_LOAD_SHARD_COUNT_THRESHOLD as int: %w", err)
		}
		if asInt < 0 {
			return fmt.Errorf("LAZY_LOAD_SHARD_COUNT_THRESHOLD must be >= 0")
		}
		config.LazyLoadShardCountThreshold = asInt
		if config.LazyLoadShardCountThreshold == 0 {
			v := true
			config.EnableLazyLoadShards = &v
		}
	} else {
		config.LazyLoadShardCountThreshold = DefaultLazyLoadShardCountThreshold
	}

	// Written only when the variable is set, so a value from the config file
	// survives.
	if v := os.Getenv("LAZY_LOAD_SHARD_WARMUP_MIN_OBJECTS"); v != "" {
		asInt, err := strconv.ParseInt(v, 10, 64)
		if err != nil {

View on GitHub (pinned to 75aa4b6d11)

Solutions

  1. Set the env var to a plain integer, e.g. LAZY_LOAD_SHARD_COUNT_THRESHOLD=100.
  2. Unset it to use the default threshold.
  3. Quote/escape values in helm/compose so no whitespace or units leak in.

Example fix

// before
LAZY_LOAD_SHARD_COUNT_THRESHOLD=10.5
// after
LAZY_LOAD_SHARD_COUNT_THRESHOLD=10
Defensive patterns

Strategy: validation

Validate before calling

v := os.Getenv("LAZY_LOAD_SHARD_COUNT_THRESHOLD")
if v != "" {
    n, err := strconv.Atoi(strings.TrimSpace(v))
    if err != nil || n < 0 {
        return fmt.Errorf("invalid LAZY_LOAD_SHARD_COUNT_THRESHOLD %q", v)
    }
}

Type guard

func validInt(v string) bool {
    _, err := strconv.Atoi(v)
    return err == nil
}

Prevention

When it happens

Trigger: LAZY_LOAD_SHARD_COUNT_THRESHOLD set to a non-integer string such as "10.5", "auto", "1,000", "0x20", or a value with units/whitespace (" 12 ") when FromEnv runs during LoadConfig.

Common situations: Copy-pasting a percentage or float from docs; shell/locale formatting with thousand separators; YAML/JSON values in helm charts rendered unquoted into the env; typos like "12o".

Understand the failure class

Background: "is not a valid" / "Invalid ... value" environment variable errors: how libraries validate env vars and what to do when they reject yours — this error's family across 48 libraries.

Related errors


AI-assisted analysis of weaviate/weaviate@75aa4b6d11 (2026-09-04). Data as JSON: /api/errors/2accaa2a89c1bcc0. Report an issue: GitHub.