{"record":{"id":"37b678048b3fca6f","repo":"weaviate/weaviate","slug":"wrong-topk-configuration-values-should-be-greater","errorCode":null,"errorMessage":"Wrong topK configuration, values should be greater than zero or nil","messagePattern":"Wrong topK configuration, values should be greater than zero or nil","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"modules/generative-databricks/config/class_settings.go","lineNumber":79,"sourceCode":"\n\ttemperature := ic.getFloatProperty(temperatureProperty, &DefaultDatabricksTemperature)\n\tif temperature == nil || (*temperature < 0 || *temperature > 1) {\n\t\treturn errors.Errorf(\"Wrong temperature configuration, values are between 0.0 and 1.0\")\n\t}\n\n\tmaxTokens := ic.getIntProperty(maxTokensProperty, nil)\n\tif maxTokens != nil && *maxTokens <= 0 {\n\t\treturn errors.Errorf(\"Wrong maxTokens configuration, values should be greater than zero or nil\")\n\t}\n\n\ttopP := ic.getFloatProperty(topPProperty, &DefaultDatabricksTopP)\n\tif topP == nil || (*topP < 0 || *topP > 5) {\n\t\treturn errors.Errorf(\"Wrong topP configuration, values are should have a minimal value of 1 and max of 5\")\n\t}\n\n\ttopK := ic.getIntProperty(topKProperty, &DefaultDatabricksTopK)\n\tif topK != nil && (*topK <= 0) {\n\t\treturn errors.Errorf(\"Wrong topK configuration, values should be greater than zero or nil\")\n\t}\n\n\treturn nil\n}\n\nfunc (ic *classSettings) getStringProperty(name, defaultValue string) *string {\n\tasString := ic.propertyValuesHelper.GetPropertyAsStringWithNotExists(ic.cfg, name, \"\", defaultValue)\n\treturn &asString\n}\n\nfunc (ic *classSettings) getFloatProperty(name string, defaultValue *float64) *float64 {\n\twrongVal := float64(-1.0)\n\treturn ic.propertyValuesHelper.GetPropertyAsFloat64WithNotExists(ic.cfg, name, &wrongVal, defaultValue)\n}\n\nfunc (ic *classSettings) getIntProperty(name string, defaultValue *int) *int {\n\twrongVal := -1\n\treturn ic.propertyValuesHelper.GetPropertyAsIntWithNotExists(ic.cfg, name, &wrongVal, defaultValue)","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/weaviate/weaviate/blob/75aa4b6d11f8818305aafd4440b4e32794f7ca04/modules/generative-databricks/config/class_settings.go#L61-L97","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Remove the topK property from the generative-databricks config so the default (DefaultDatabricksTopK) is used.","Set topK to a positive integer (e.g. topK: 1 or higher) appropriate for the hosted model.","If config comes from a template/CI pipeline, ensure unset topK values are omitted rather than emitted as 0."],"exampleFix":"// before\n{\"moduleConfig\":{\"generative-databricks\":{\"topK\":0}}}\n// after\n{\"moduleConfig\":{\"generative-databricks\":{\"topK\":4}}}","handlingStrategy":"validation","validationCode":"function validateDatabricksTopK(cfg) {\n  const topK = cfg?.moduleConfig?.['generative-databricks']?.topK;\n  if (topK === undefined || topK === null) return true;\n  if (!Number.isInteger(topK) || topK <= 0) {\n    throw new Error(`topK must be a positive integer or omitted, got ${topK}`);\n  }\n  return true;\n}","typeGuard":"function isValidTopK(v) {\n  return v === undefined || v === null || (Number.isInteger(v) && v > 0);\n}","tryCatchPattern":null,"preventionTips":["Treat omitted (nil) topK as the 'default' signal — never encode 'default' as 0.","Validate generative module configs against the module's OpenAPI/GraphQL schema before submitting.","Ensure config templates omit unset numeric fields rather than emitting zeros."],"tags":["weaviate","generative-databricks","configuration","validation"],"backgroundTag":"invalid-argument-value","analyzedSha":"75aa4b6d11f8818305aafd4440b4e32794f7ca04","analyzedAt":"2026-09-04T14:58:20.392Z","contentChangedAt":"2026-09-04T14:58:20.392Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}