{"record":{"id":"4043a6582efd33cb","repo":"actualbudget/actual","slug":"last-implies-table-transactions-cannot-use-wi","errorCode":null,"errorMessage":"--last implies --table transactions. Cannot use with --table ${cmdOpts.table}","messagePattern":"--last implies --table transactions\\. Cannot use with --table (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cli/src/commands/query.ts","lineNumber":149,"sourceCode":"  if (Array.isArray(parsed.orderBy)) {\n    queryObj = queryObj.orderBy(parsed.orderBy);\n  }\n  if (typeof parsed.limit === 'number') queryObj = queryObj.limit(parsed.limit);\n  if (typeof parsed.offset === 'number') {\n    queryObj = queryObj.offset(parsed.offset);\n  }\n  if (Array.isArray(parsed.groupBy)) {\n    queryObj = queryObj.groupBy(parsed.groupBy);\n  }\n  return queryObj;\n}\n\nfunction buildQueryFromFlags(cmdOpts: Record<string, string | undefined>) {\n  const last = cmdOpts.last ? parseIntFlag(cmdOpts.last, '--last') : undefined;\n\n  if (last !== undefined) {\n    if (cmdOpts.table && cmdOpts.table !== 'transactions') {\n      throw new Error(\n        '--last implies --table transactions. Cannot use with --table ' +\n          cmdOpts.table,\n      );\n    }\n    if (cmdOpts.limit) {\n      throw new Error('--last and --limit are mutually exclusive');\n    }\n  }\n\n  const table =\n    cmdOpts.table ?? (last !== undefined ? 'transactions' : undefined);\n  if (!table) {\n    throw new Error('--table is required (or use --file or --last)');\n  }\n\n  if (!(table in TABLE_SCHEMA)) {\n    throw new Error(\n      `Unknown table \"${table}\". Available tables: ${AVAILABLE_TABLES}`,","sourceCodeStart":131,"sourceCodeEnd":167,"githubUrl":"https://github.com/actualbudget/actual/blob/d4334cb6e6123f4d3bcea1ad6166608884c7e658/packages/cli/src/commands/query.ts#L131-L167","documentation":"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.","triggerScenarios":"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).","commonSituations":"Copy-editing a transactions query to point at another table while keeping `--last`; scripted flag composition that appends `--last` unconditionally.","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."],"exampleFix":"// before\nactual query --last 30 --table categories\n// after\nactual query --last 30","handlingStrategy":"validation","validationCode":"if (last !== undefined && table !== undefined && table !== 'transactions') {\n  throw new Error('--last only works with the transactions table');\n}","typeGuard":null,"tryCatchPattern":"try {\n  await cli(['query', ...args]);\n} catch (e) {\n  if (e.message.includes('--last implies --table transactions')) {\n    console.error('Drop --table or set it to transactions when using --last');\n  }\n}","preventionTips":["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."],"tags":["cli","validation","conflicting-flags"],"backgroundTag":"mutually-exclusive-flags","analyzedSha":"d4334cb6e6123f4d3bcea1ad6166608884c7e658","analyzedAt":"2026-08-29T01:02:11.213Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}