FlowiseAI/Flowise · error · Error
Values must be a valid JSON array
Error message
Values must be a valid JSON array
What it means
Thrown inside UpdateValuesTool._call when JSON.parse(params.values) throws. The UpdateValuesSchema declares values as a string that must itself be valid JSON (e.g. "[[\"A1\",\"B1\"]]"), because the tool serializes the parsed array into the Google Sheets values body. The inner try/catch converts any parse failure — SyntaxError from a trailing comma, unquoted key, or a raw non-JSON string — into this fixed message, discarding the original parse error.
Source
Thrown at packages/components/nodes/tools/GoogleSheets/core.ts:390
method: 'PUT',
headers: {}
}
super({
...toolInput,
accessToken: args.accessToken
})
this.defaultParams = args.defaultParams || {}
}
async _call(arg: any): Promise<string> {
const params = { ...arg, ...this.defaultParams }
try {
let values
try {
values = JSON.parse(params.values)
} catch (error) {
throw new Error('Values must be a valid JSON array')
}
const body = {
values,
majorDimension: params.majorDimension || 'ROWS'
}
const queryParams = new URLSearchParams()
queryParams.append('valueInputOption', params.valueInputOption || 'USER_ENTERED')
const encodedRange = encodeURIComponent(params.range)
const endpoint = `spreadsheets/${params.spreadsheetId}/values/${encodedRange}?${queryParams.toString()}`
return await this.makeGoogleSheetsRequest({
endpoint,
method: 'PUT',
body,
paramsView on GitHub (pinned to abe4a8601a)
Solutions
- Pre-stringify the array exactly once before assigning to values: values: JSON.stringify([["A1","B1"]]).
- Validate with JSON.parse in a guard before invoking the tool so you get the real parse error position.
- If the source is an agent, tighten the schema description or add a few-shot example showing the double-bracket string shape.
- Confirm defaultParams.values is not simultaneously set to a different shape than arg.values (the spread { ...arg, ...this.defaultParams } lets defaults clobber a good arg).
Example fix
// before — values is a CSV-like string, parse fails
const res = await updateValues.invoke({ spreadsheetId, range: 'A1:B1', values: 'a,b' })
// after — values is a JSON-stringified 2D array
const res = await updateValues.invoke({ spreadsheetId, range: 'A1:B1', values: JSON.stringify([['a','b']]) }) Defensive patterns
Strategy: validation
Validate before calling
function asValues2D(input: unknown): string {
// accept array, JSON string of array, or fail fast with a clear error
let arr: unknown
if (typeof input === 'string') {
arr = JSON.parse(input) // throws precise error if bad
} else {
arr = input
}
if (!Array.isArray(arr) || !arr.every(r => Array.isArray(r))) {
throw new Error('values must be a 2D array (string[][]), got: ' + JSON.stringify(arr).slice(0,120))
}
return JSON.stringify(arr)
}
// then: values: asValues2D(raw) Type guard
function is2DStringArray(v: unknown): v is string[][] {
return Array.isArray(v) && v.every(r => Array.isArray(r) && r.every(c => typeof c === 'string'))
} Try / catch
try {
return await updateValues.invoke({ ..., values: asValues2D(raw) })
} catch (e) {
if (e instanceof Error && e.message === 'Values must be a valid JSON array') {
return { error: 'malformed values', raw } // feed back to agent
}
throw e
} Prevention
- Always JSON.stringify the 2D array exactly once before passing it as values.
- Strip dynamic cell content of control characters and unescaped quotes.
- In agent prompts, show the literal shape [["A1","B1"]] as a few-shot example.
- Assert defaultParams.values and arg.values aren't both set to incompatible shapes.
When it happens
Trigger: An LLM agent supplies params.values as a bare array literal "[[a,b]]" without quotes, as a comma-separated list "a,b,c", as a JS object "{values:[[1]]}", or with smart-quotes/special whitespace. Also triggered when defaultParams.values and arg.values merge into a doubled/corrupted string, or when an upstream node emits the array as "[object Array]".
Common situations: Agent models that emit CSV instead of JSON; a previous node passes a stringified array that gets stringified again (double-encoded "\\\"[[1]]\\\""); copy-paste from a spreadsheet cell that contains a leading apostrophe; locale decimal separators (1,5) leaking into the JSON.
Related errors
- Values must be a valid JSON array of value ranges
- Invalid JSON string: ${error instanceof Error ? error.messag
- chatflowId must be a valid array
- Invalid JSON in executeFlowOverrideConfig: ${parseError.mess
- Invalid input array
AI-assisted analysis of FlowiseAI/Flowise@abe4a8601a (2026-08-12).
Data as JSON: /api/errors/eedfa1992eb446d7.
Report an issue: GitHub.