{"record":{"id":"4ac7ee64fbf3ddde","repo":"actualbudget/actual","slug":"too-many-arguments","errorCode":null,"errorMessage":"Too many arguments","messagePattern":"Too many arguments","errorType":"exception","errorClass":"CompileError","httpStatus":null,"severity":"error","filePath":"packages/loot-core/src/server/aql/compiler.ts","lineNumber":377,"sourceCode":"  }\n\n  return castedExpr.value;\n}\n\nfunction valArray(state, arr: unknown[], types?: string[]) {\n  return arr.map((value, idx) => val(state, value, types ? types[idx] : null));\n}\n\nfunction validateArgLength(arr: unknown[], min: number, max?: number) {\n  if (max == null) {\n    max = min;\n  }\n\n  if (min != null && arr.length < min) {\n    throw new CompileError('Too few arguments');\n  }\n  if (max != null && arr.length > max) {\n    throw new CompileError('Too many arguments');\n  }\n}\n\n//// Nice errors\n\nfunction saveStack(type, func) {\n  return (state, ...args) => {\n    if (state == null || state.compileStack == null) {\n      throw new CompileError(\n        'This function cannot track error data. ' +\n          'It needs to accept the compiler state as the first argument.',\n      );\n    }\n\n    state.compileStack.push({ type, args });\n    const ret = func(state, ...args);\n    state.compileStack.pop();\n    return ret;","sourceCodeStart":359,"sourceCodeEnd":395,"githubUrl":"https://github.com/actualbudget/actual/blob/d4334cb6e6123f4d3bcea1ad6166608884c7e658/packages/loot-core/src/server/aql/compiler.ts#L359-L395","documentation":"The counterpart of 'Too few arguments': validateArgLength throws when a function call supplies more arguments than the declared maximum. CompileError 'Too many arguments' is raised from compileFunction.","triggerScenarios":"Passing extra positional arguments to a fixed-arity AQL function, e.g. 4 args to $cond (max 3) or 2 args to a unary function like $neg.","commonSituations":"Migrating from another query language's syntax that allows optional extra params; typos leaving a stray argument in the array; a builder appending default arguments the schema doesn't accept.","solutions":["Remove the extra arguments to match the function's declared arity","Check the function schema for the accepted min/max argument count","If you need optional behavior, use the documented function for it instead of extra args","Verify no duplicated/accidental element exists in the arguments array"],"exampleFix":"// before\n{ $cond: [amount > 0, 'credit', 'debit', 'other'] }\n// after\n{ $cond: [amount > 0, 'credit', 'debit'] }","handlingStrategy":"validation","validationCode":"if (args.length > maxAllowed) {\n  throw new Error(`${fnName} accepts at most ${maxAllowed} arguments, got ${args.length}`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  compileQuery(query);\n} catch (e) {\n  if (e.message === 'Too many arguments') {\n    console.error('Extra argument in query function call', { query });\n  }\n  throw e;\n}","preventionTips":["Match argument count to the function schema exactly","Don't append 'extra optional' args that the schema doesn't define","Review migrated query syntax for leftover positional args"],"tags":["aql","query-compiler","argument-validation"],"backgroundTag":"wrong-argument-count","analyzedSha":"d4334cb6e6123f4d3bcea1ad6166608884c7e658","analyzedAt":"2026-08-29T01:02:11.213Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}