{"record":{"id":"e4297eb398e9dcdd","repo":"wavetermdev/waveterm","slug":"values-must-be-an-array","errorCode":null,"errorMessage":"values must be an array","messagePattern":"values must be an array","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/aiusechat/tools.go","lineNumber":299,"sourceCode":"\t\t\t\t},\n\t\t\t},\n\t\t\t\"required\":             []string{\"values\"},\n\t\t\t\"additionalProperties\": false,\n\t\t},\n\t\tToolAnyCallback: func(input any, toolUseData *uctypes.UIMessageDataToolUse) (any, error) {\n\t\t\tinputMap, ok := input.(map[string]any)\n\t\t\tif !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"invalid input format\")\n\t\t\t}\n\n\t\t\tvaluesInterface, ok := inputMap[\"values\"]\n\t\t\tif !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"missing values parameter\")\n\t\t\t}\n\n\t\t\tvaluesSlice, ok := valuesInterface.([]any)\n\t\t\tif !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"values must be an array\")\n\t\t\t}\n\n\t\t\tif len(valuesSlice) == 0 {\n\t\t\t\treturn 0, nil\n\t\t\t}\n\n\t\t\tsum := 0\n\t\t\tfor i, val := range valuesSlice {\n\t\t\t\tfloatVal, ok := val.(float64)\n\t\t\t\tif !ok {\n\t\t\t\t\treturn nil, fmt.Errorf(\"value at index %d is not a number\", i)\n\t\t\t\t}\n\t\t\t\tsum += int(floatVal)\n\t\t\t}\n\n\t\t\treturn sum, nil\n\t\t},\n\t}","sourceCodeStart":281,"sourceCodeEnd":317,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/pkg/aiusechat/tools.go#L281-L317","documentation":"The \"values\" key exists but its value is not a JSON array ([]any). The callback type-asserts valuesInterface.([]any) and returns this error on failure. Note an empty array is explicitly allowed (returns sum 0), so this error is strictly about the wrong type, not emptiness.","triggerScenarios":"Tool called with values as a non-array: e.g. {\"values\": 5}, {\"values\": \"1,2,3\"}, {\"values\": {\"0\":1}}, or null.","commonSituations":"Model passing a comma-separated string instead of an array; passing a single number instead of a one-element array; passing an object keyed by indices; client SDK serializing variadic args as scalars.","solutions":["Pass values as a JSON array: {\"values\": [1, 2, 3]} — not a string, number, or object","If the model keeps sending strings, strengthen the tool description with an explicit example showing an array literal","Validate client-side before invoking: check Array.isArray(values) / reflect.Kind Slice before calling the tool"],"exampleFix":"// before\nanySum({\"values\": \"1,2,3\"})\n// after\nanySum({\"values\": [1, 2, 3]})","handlingStrategy":"type-guard","validationCode":"raw, ok := m[\"values\"]; if !ok { return errors.New(\"values required\") }; if _, ok := raw.([]any); !ok { return errors.New(\"values must be a JSON array\") }","typeGuard":"func isAnySlice(v any) ([]any, bool) { s, ok := v.([]any); return s, ok }","tryCatchPattern":"out, err := tool.Call(input); if err != nil && strings.Contains(err.Error(), \"values must be an array\") { return fmt.Errorf(\"bad tool args: %w\", err) }","preventionTips":["Never quote the array or pass a single scalar; always [1,2,3]","Include an array example in the tool description for the model","Coerce strings like \"1,2,3\" into arrays before calling"],"tags":["tool-input","type-mismatch","array-validation"],"backgroundTag":"parameter-type-mismatch","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}