actualbudget/actual · error · CompileError
Too many arguments
Error message
Too many arguments
What it means
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.
Source
Thrown at packages/loot-core/src/server/aql/compiler.ts:377
}
return castedExpr.value;
}
function valArray(state, arr: unknown[], types?: string[]) {
return arr.map((value, idx) => val(state, value, types ? types[idx] : null));
}
function validateArgLength(arr: unknown[], min: number, max?: number) {
if (max == null) {
max = min;
}
if (min != null && arr.length < min) {
throw new CompileError('Too few arguments');
}
if (max != null && arr.length > max) {
throw new CompileError('Too many arguments');
}
}
//// Nice errors
function saveStack(type, func) {
return (state, ...args) => {
if (state == null || state.compileStack == null) {
throw new CompileError(
'This function cannot track error data. ' +
'It needs to accept the compiler state as the first argument.',
);
}
state.compileStack.push({ type, args });
const ret = func(state, ...args);
state.compileStack.pop();
return ret;View on GitHub (pinned to d4334cb6e6)
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
Example fix
// before
{ $cond: [amount > 0, 'credit', 'debit', 'other'] }
// after
{ $cond: [amount > 0, 'credit', 'debit'] } Defensive patterns
Strategy: validation
Validate before calling
if (args.length > maxAllowed) {
throw new Error(`${fnName} accepts at most ${maxAllowed} arguments, got ${args.length}`);
} Try / catch
try {
compileQuery(query);
} catch (e) {
if (e.message === 'Too many arguments') {
console.error('Extra argument in query function call', { query });
}
throw e;
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Too few arguments
- Table "${tableName}" does not exist in the schema
- Can't cast ${expr.type} to date
- Can't cast ${expr.type} to date-month
- Can't cast ${expr.type} to date-year
AI-assisted analysis of actualbudget/actual@d4334cb6e6 (2026-08-29).
Data as JSON: /api/errors/4ac7ee64fbf3ddde.
Report an issue: GitHub.