actualbudget/actual · error · Error
--last implies --table transactions. Cannot use with --table
Error message
--last implies --table transactions. Cannot use with --table ${cmdOpts.table} What it means
The `--last` flag is a shorthand for querying the most recent transactions, so it implicitly forces the table to `transactions`. If you combine `--last` with an explicit `--table` set to anything other than `transactions`, the intent is contradictory and `buildQueryFromFlags` throws this error.
Source
Thrown at packages/cli/src/commands/query.ts:149
if (Array.isArray(parsed.orderBy)) {
queryObj = queryObj.orderBy(parsed.orderBy);
}
if (typeof parsed.limit === 'number') queryObj = queryObj.limit(parsed.limit);
if (typeof parsed.offset === 'number') {
queryObj = queryObj.offset(parsed.offset);
}
if (Array.isArray(parsed.groupBy)) {
queryObj = queryObj.groupBy(parsed.groupBy);
}
return queryObj;
}
function buildQueryFromFlags(cmdOpts: Record<string, string | undefined>) {
const last = cmdOpts.last ? parseIntFlag(cmdOpts.last, '--last') : undefined;
if (last !== undefined) {
if (cmdOpts.table && cmdOpts.table !== 'transactions') {
throw new Error(
'--last implies --table transactions. Cannot use with --table ' +
cmdOpts.table,
);
}
if (cmdOpts.limit) {
throw new Error('--last and --limit are mutually exclusive');
}
}
const table =
cmdOpts.table ?? (last !== undefined ? 'transactions' : undefined);
if (!table) {
throw new Error('--table is required (or use --file or --last)');
}
if (!(table in TABLE_SCHEMA)) {
throw new Error(
`Unknown table "${table}". Available tables: ${AVAILABLE_TABLES}`,View on GitHub (pinned to d4334cb6e6)
Solutions
- Drop `--table` entirely when using `--last` (it defaults to transactions).
- Keep `--table transactions` if you must state it explicitly.
- Replace `--last` with `--limit` and an appropriate filter if you meant to query a non-transactions table.
Example fix
// before actual query --last 30 --table categories // after actual query --last 30
Defensive patterns
Strategy: validation
Validate before calling
if (last !== undefined && table !== undefined && table !== 'transactions') {
throw new Error('--last only works with the transactions table');
} Try / catch
try {
await cli(['query', ...args]);
} catch (e) {
if (e.message.includes('--last implies --table transactions')) {
console.error('Drop --table or set it to transactions when using --last');
}
} Prevention
- Treat --last as transactions-only shorthand and never pair it with --table.
- Use --table + --limit (+ --where) for non-transaction tables.
- Centralize flag composition in scripts so --last and --table are not mixed.
When it happens
Trigger: Running e.g. `actual query --last 30 --table categories` — `--last` with a `--table` value other than `transactions` (an omitted `--table` is fine because it defaults to transactions).
Common situations: Copy-editing a transactions query to point at another table while keeping `--last`; scripted flag composition that appends `--last` unconditionally.
Related errors
- --last and --limit are mutually exclusive
- Invalid --name: must be a non-empty string.
- No update fields provided. Use --name or --offbudget.
- Invalid cutoff date: expected a valid date (e.g. YYYY-MM-DD)
- No update fields provided. Use --name or --hidden.
AI-assisted analysis of actualbudget/actual@d4334cb6e6 (2026-08-29).
Data as JSON: /api/errors/4043a6582efd33cb.
Report an issue: GitHub.