weaviate/weaviate · error

Wrong topK configuration, values should be greater than zero

Error message

Wrong topK configuration, values should be greater than zero or nil

What it means

This is a schema validation error thrown by the generative-databricks module's class settings validator when a generative-databricks config sets topK to a non-positive value. The module requires topK to be either nil (use the module default) or an integer greater than zero; otherwise the Databricks-hosted model would receive an invalid sampling parameter. Weaviate refuses to create or update the collection with such a configuration.

Source

Thrown at modules/generative-databricks/config/class_settings.go:79

	temperature := ic.getFloatProperty(temperatureProperty, &DefaultDatabricksTemperature)
	if temperature == nil || (*temperature < 0 || *temperature > 1) {
		return errors.Errorf("Wrong temperature configuration, values are between 0.0 and 1.0")
	}

	maxTokens := ic.getIntProperty(maxTokensProperty, nil)
	if maxTokens != nil && *maxTokens <= 0 {
		return errors.Errorf("Wrong maxTokens configuration, values should be greater than zero or nil")
	}

	topP := ic.getFloatProperty(topPProperty, &DefaultDatabricksTopP)
	if topP == nil || (*topP < 0 || *topP > 5) {
		return errors.Errorf("Wrong topP configuration, values are should have a minimal value of 1 and max of 5")
	}

	topK := ic.getIntProperty(topKProperty, &DefaultDatabricksTopK)
	if topK != nil && (*topK <= 0) {
		return errors.Errorf("Wrong topK configuration, values should be greater than zero or nil")
	}

	return nil
}

func (ic *classSettings) getStringProperty(name, defaultValue string) *string {
	asString := ic.propertyValuesHelper.GetPropertyAsStringWithNotExists(ic.cfg, name, "", defaultValue)
	return &asString
}

func (ic *classSettings) getFloatProperty(name string, defaultValue *float64) *float64 {
	wrongVal := float64(-1.0)
	return ic.propertyValuesHelper.GetPropertyAsFloat64WithNotExists(ic.cfg, name, &wrongVal, defaultValue)
}

func (ic *classSettings) getIntProperty(name string, defaultValue *int) *int {
	wrongVal := -1
	return ic.propertyValuesHelper.GetPropertyAsIntWithNotExists(ic.cfg, name, &wrongVal, defaultValue)

View on GitHub (pinned to 75aa4b6d11)

Solutions

  1. Remove the topK property from the generative-databricks config so the default (DefaultDatabricksTopK) is used.
  2. Set topK to a positive integer (e.g. topK: 1 or higher) appropriate for the hosted model.
  3. If config comes from a template/CI pipeline, ensure unset topK values are omitted rather than emitted as 0.

Example fix

// before
{"moduleConfig":{"generative-databricks":{"topK":0}}}
// after
{"moduleConfig":{"generative-databricks":{"topK":4}}}
Defensive patterns

Strategy: validation

Validate before calling

function validateDatabricksTopK(cfg) {
  const topK = cfg?.moduleConfig?.['generative-databricks']?.topK;
  if (topK === undefined || topK === null) return true;
  if (!Number.isInteger(topK) || topK <= 0) {
    throw new Error(`topK must be a positive integer or omitted, got ${topK}`);
  }
  return true;
}

Type guard

function isValidTopK(v) {
  return v === undefined || v === null || (Number.isInteger(v) && v > 0);
}

Prevention

When it happens

Trigger: Creating or updating a collection whose generative-databricks moduleConfig sets topK to 0 or a negative number, e.g. {"moduleConfig":{"generative-databricks":{"topK":0}}}. Validation runs during schema validation (classSettings.Validate), before the config is accepted.

Common situations: Developers copying OpenAI-style configs where topK: 0 is used to mean 'disabled'; templating tools injecting unset variables as 0 instead of omitting the field; accidentally serializing a default-int zero into the config instead of nil.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


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