{"record":{"id":"799d9b61938fccb4","repo":"actualbudget/actual","slug":"last-and-limit-are-mutually-exclusive","errorCode":null,"errorMessage":"--last and --limit are mutually exclusive","messagePattern":"--last and --limit are mutually exclusive","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cli/src/commands/query.ts","lineNumber":155,"sourceCode":"  }\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}`,\n    );\n  }\n\n  if (cmdOpts.where && cmdOpts.filter) {\n    throw new Error('--where and --filter are mutually exclusive');\n  }","sourceCodeStart":137,"sourceCodeEnd":173,"githubUrl":"https://github.com/actualbudget/actual/blob/d4334cb6e6123f4d3bcea1ad6166608884c7e658/packages/cli/src/commands/query.ts#L137-L173","documentation":"`--last` already caps the number of returned rows (it means 'the last N transactions'), so combining it with the generic `--limit` flag is ambiguous. When both are provided the command throws this error instead of guessing which count applies.","triggerScenarios":"Running `actual query --last 30 --limit 10` — both flags present, `--last` having parsed to a valid number.","commonSituations":"Adding `--limit` to an existing `--last` command to 'narrow' results; composing flags in scripts where one flag comes from a config file and the other from the command line.","solutions":["Keep only `--last N` (it already limits results).","Or use `--limit N` alone with `--table transactions` if you do not need 'most recent' semantics.","Ensure scripts do not inject both flags from different sources."],"exampleFix":"// before\nactual query --last 30 --limit 10\n// after\nactual query --last 30","handlingStrategy":"validation","validationCode":"if (last !== undefined && limit !== undefined) {\n  throw new Error('choose either --last or --limit, not both');\n}","typeGuard":null,"tryCatchPattern":"try {\n  await cli(['query', ...args]);\n} catch (e) {\n  if (e.message.includes('--last and --limit are mutually exclusive')) {\n    console.error('Remove one of --last / --limit');\n  }\n}","preventionTips":["Pick one row-limiting flag per invocation: --last for recent transactions, --limit otherwise.","When merging flags from config + CLI, ensure only one limit source wins.","Remember --last already implies a limit of N."],"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"}