{"record":{"id":"8897539ecaabb9a2","repo":"weaviate/weaviate","slug":"json-number-to-int64-for-q","errorCode":null,"errorMessage":"json.Number to int64 for %q","messagePattern":"json\\.Number to int64 for %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"entities/vectorindex/common/config.go","lineNumber":71,"sourceCode":"\tvar asInt64 int64\n\tvar err error\n\n\t// depending on whether we get the results from disk or from the REST API,\n\t// numbers may be represented slightly differently\n\tswitch typed := value.(type) {\n\tcase json.Number:\n\t\tasInt64, err = typed.Int64()\n\tcase float64:\n\t\tasInt64 = int64(typed)\n\t}\n\tif err != nil {\n\t\t// try to recover from error\n\t\tif errors.Is(err, strconv.ErrRange) {\n\t\t\tsetFn(int(math.MaxInt64))\n\t\t\treturn nil\n\t\t}\n\n\t\treturn errors.Wrapf(err, \"json.Number to int64 for %q\", name)\n\t}\n\n\tsetFn(int(asInt64))\n\treturn nil\n}\n\nfunc OptionalBoolFromMap(in map[string]interface{}, name string,\n\tsetFn func(v bool),\n) error {\n\tvalue, ok := in[name]\n\tif !ok {\n\t\treturn nil\n\t}\n\n\tasBool, ok := value.(bool)\n\tif !ok {\n\t\treturn nil\n\t}","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/weaviate/weaviate/blob/75aa4b6d11f8818305aafd4440b4e32794f7ca04/entities/vectorindex/common/config.go#L53-L89","documentation":"Wraps a strconv failure raised inside OptionalIntFromMap when a json.Number from a config map cannot be converted to int64. Only range/overflow-style errors reach this wrap; ErrRange is recovered by clamping to MaxInt64, so this fires when the number is invalid in another way (e.g. not a valid numeric literal).","triggerScenarios":"Passing a config map (e.g. from vectorIndexConfig for PQ/RQ/SQ/multivector settings) whose value for the named key is a json.Number that fails AsInt64 — typically a malformed or non-integral numeric value embedded in module or index config JSON.","commonSituations":"Hand-edited collection configs, class definitions copied from docs with invalid numeric values, or programmatic config generation emitting wrong numeric types.","solutions":["Fix the offending numeric value in the vectorIndexConfig for the named key so it is a valid integer","Validate the class config JSON with the schema validation endpoint before applying","Check the key name in the error message and correct that specific field (e.g. PQ segments, SQ rescore limit)","Use the client library's typed config builders instead of raw maps"],"exampleFix":"// before\n\"vectorIndexConfig\": { \"maxConnections\": \"abc\" }\n// after\n\"vectorIndexConfig\": { \"maxConnections\": 64 }","handlingStrategy":"validation","validationCode":"func isIntConfig(m map[string]interface{}, key string) bool {\n    n, ok := m[key].(json.Number)\n    if !ok { return false }\n    _, err := n.Int64()\n    return err == nil\n}","typeGuard":"func asInt(v interface{}) (int64, bool) {\n    n, ok := v.(json.Number)\n    if !ok { return 0, false }\n    i, err := n.Int64()\n    return i, err == nil\n}","tryCatchPattern":"if err := cfg.Validate(); err != nil {\n    return fmt.Errorf(\"invalid vectorIndexConfig: %w\", err)\n}","preventionTips":["Validate class definitions with the schema validation endpoint before creating collections","Use typed client SDK config builders instead of raw JSON maps","Ensure numeric config fields are unquoted integers in JSON","Review hand-edited configs for typos in numeric fields"],"tags":["config","json","parsing"],"backgroundTag":"invalid-config-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"}