{"record":{"id":"e523748804d7dc8b","repo":"nats-io/nats-server","slug":"min-version-wrong-type-v","errorCode":null,"errorMessage":"'min_version' wrong type: %v","messagePattern":"'min_version' wrong type: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/opts.go","lineNumber":5116,"sourceCode":"func parseCurvePreferences(curveName string) (tls.CurveID, error) {\n\tcurve, exists := curvePreferenceMap[curveName]\n\tif !exists {\n\t\treturn 0, fmt.Errorf(\"unrecognized curve preference %s\", curveName)\n\t}\n\treturn curve, nil\n}\n\nfunc parseTLSVersion(v any) (uint16, error) {\n\tvar tlsVersionNumber uint16\n\tswitch v := v.(type) {\n\tcase string:\n\t\tn, err := tlsVersionFromString(v)\n\t\tif err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t\ttlsVersionNumber = n\n\tdefault:\n\t\treturn 0, fmt.Errorf(\"'min_version' wrong type: %v\", v)\n\t}\n\tif tlsVersionNumber < tls.VersionTLS12 {\n\t\treturn 0, fmt.Errorf(\"unsupported TLS version: %s\", tls.VersionName(tlsVersionNumber))\n\t}\n\treturn tlsVersionNumber, nil\n}\n\n// Helper function to parse TLS configs.\nfunc parseTLS(v any, isClientCtx bool) (t *TLSConfigOpts, retErr error) {\n\tvar (\n\t\ttlsm map[string]any\n\t\ttc   = TLSConfigOpts{}\n\t\tlt   token\n\t\tics  []*tls.CipherSuite // Insecure ciphers found\n\t)\n\tdefer convertPanicToError(&lt, &retErr)\n\n\ttk, v := unwrapValue(v, &lt)","sourceCodeStart":5098,"sourceCodeEnd":5134,"githubUrl":"https://github.com/nats-io/nats-server/blob/3a66a489d262bf89b71a71c955c94920394532f3/server/opts.go#L5098-L5134","documentation":"parseTLSVersion accepts either a string version name (via tlsVersionFromString) or a numeric TLS version, and returns this error in its default case when the 'min_version' value is neither of those types. It is a type validation error: the YAML/JSON config value has an unexpected Go type.","triggerScenarios":"Setting min_version (or related version fields) in TLS config to a non-string, non-numeric YAML/JSON value such as a bool, list, or map, e.g. 'min_version: true'.","commonSituations":"YAML config where a version string was unquoted and parsed as something unexpected; copy-paste errors nesting wrong values under tls block.","solutions":["Set min_version to a quoted string like \"1.2\" or \"1.3\"","Or use a plain integer TLS version constant value","Verify the parsed YAML/JSON type of the field before passing to parseTLS"],"exampleFix":"// before (YAML)\nmin_version: [1.2]\n// after\nmin_version: \"1.2\"","handlingStrategy":"type-guard","validationCode":"v, ok := cfg[\"min_version\"]\nif !ok || !(isString(v) || isNumber(v)) {\n  return fmt.Errorf(\"min_version must be a string or number, got %T\", v)\n}","typeGuard":"func isTLSType(v interface{}) bool {\n  switch v.(type) { case string, int, float64: return true }\n  return false\n}","tryCatchPattern":"if _, err := parseTLSVersion(raw); err != nil { log.Fatalf(\"bad min_version: %v\", err) }","preventionTips":["Quote TLS version strings in YAML (\"1.2\")","Assert config types against a JSON schema before load","Avoid building tls maps with dynamic values"],"tags":["tls","type-error","config-validation"],"backgroundTag":"tls-config-type-error","analyzedSha":"3a66a489d262bf89b71a71c955c94920394532f3","analyzedAt":"2026-09-02T04:41:54.247Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}