weaviate/weaviate · error
json.Number to int64 for %q
Error message
json.Number to int64 for %q
What it means
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).
Source
Thrown at entities/vectorindex/common/config.go:71
var asInt64 int64
var err error
// depending on whether we get the results from disk or from the REST API,
// numbers may be represented slightly differently
switch typed := value.(type) {
case json.Number:
asInt64, err = typed.Int64()
case float64:
asInt64 = int64(typed)
}
if err != nil {
// try to recover from error
if errors.Is(err, strconv.ErrRange) {
setFn(int(math.MaxInt64))
return nil
}
return errors.Wrapf(err, "json.Number to int64 for %q", name)
}
setFn(int(asInt64))
return nil
}
func OptionalBoolFromMap(in map[string]interface{}, name string,
setFn func(v bool),
) error {
value, ok := in[name]
if !ok {
return nil
}
asBool, ok := value.(bool)
if !ok {
return nil
}View on GitHub (pinned to 75aa4b6d11)
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
Example fix
// before
"vectorIndexConfig": { "maxConnections": "abc" }
// after
"vectorIndexConfig": { "maxConnections": 64 } Defensive patterns
Strategy: validation
Validate before calling
func isIntConfig(m map[string]interface{}, key string) bool {
n, ok := m[key].(json.Number)
if !ok { return false }
_, err := n.Int64()
return err == nil
} Type guard
func asInt(v interface{}) (int64, bool) {
n, ok := v.(json.Number)
if !ok { return 0, false }
i, err := n.Int64()
return i, err == nil
} Try / catch
if err := cfg.Validate(); err != nil {
return fmt.Errorf("invalid vectorIndexConfig: %w", err)
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: Hand-edited collection configs, class definitions copied from docs with invalid numeric values, or programmatic config generation emitting wrong numeric types.
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
Related errors
- marshal config: %w
- parse []interface{} as vector for target vector: %s: %w
- parse []interface{} as multi vector for target vector: %s: %
- malformed property json: %w
- failed to parse QnA response (status %d): %w
AI-assisted analysis of weaviate/weaviate@75aa4b6d11 (2026-09-04).
Data as JSON: /api/errors/8897539ecaabb9a2.
Report an issue: GitHub.