{"record":{"id":"2f4a91c2e8d79319","repo":"actualbudget/actual","slug":"table-tablename-does-not-exist-in-the-schema","errorCode":null,"errorMessage":"Table \"${tableName}\" does not exist in the schema","messagePattern":"Table \"(.+?)\" does not exist in the schema","errorType":"exception","errorClass":"CompileError","httpStatus":null,"severity":"error","filePath":"packages/loot-core/src/server/aql/compiler.ts","lineNumber":59,"sourceCode":"  const parts = path.split('.');\n  return { path: parts.slice(0, -1).join('.'), field: parts[parts.length - 1] };\n}\n\nfunction isKeyword(str) {\n  return str === 'group';\n}\n\nexport function quoteAlias(alias) {\n  return alias.indexOf('.') === -1 && !isKeyword(alias) ? alias : `\"${alias}\"`;\n}\n\nfunction typed(value, type, { literal = false } = {}) {\n  return { value, type, literal };\n}\n\nfunction getFieldDescription(schema, tableName, field) {\n  if (schema[tableName] == null) {\n    throw new CompileError(`Table \"${tableName}\" does not exist in the schema`);\n  }\n\n  const fieldDesc = schema[tableName][field];\n  if (fieldDesc == null) {\n    throw new CompileError(\n      `Field \"${field}\" does not exist in table \"${tableName}\"`,\n    );\n  }\n  return fieldDesc;\n}\n\nfunction makePath(state, path) {\n  const { schema, paths } = state;\n\n  const parts = path.split('.');\n  if (parts.length < 2) {\n    throw new CompileError('Invalid path: ' + path);\n  }","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/actualbudget/actual/blob/d4334cb6e6123f4d3bcea1ad6166608884c7e658/packages/loot-core/src/server/aql/compiler.ts#L41-L77","documentation":"Actual's AQL query compiler resolves every table referenced in a query against the supplied schema catalog. getFieldDescription looks up schema[tableName]; when the table is absent from the schema object it throws CompileError with this message. This guards against querying tables that don't exist (or aren't exposed to AQL) before any SQL is generated.","triggerScenarios":"Running aquery (loot-core's aql.runQuery / Query class) whose from()/table name is misspelled or not part of the schema — e.g. q('transations') instead of q('transactions'), or a custom/internal table name not registered in the schema map passed to the compiler via fieldDesc.","commonSituations":"Typo in a custom query built with the aql query builder; using an internal-only or deprecated table name after a schema rename between Actual versions; API/plugin code (actual-js) referencing tables the AQL layer doesn't expose; dynamically constructed table names built from user input.","solutions":["Correct the table name in the query to one present in the schema (transactions, accounts, payees, categories, category_groups, rules, schedules, etc.).","Check the schema map in packages/loot-core/src/server/aql/schema.ts for the exact exposed table names.","If the table was renamed in a newer Actual version, update the query to the new name.","For dynamic queries, validate the table name against Object.keys(schema) before building the query."],"exampleFix":"// before\nconst q = aql.query('transations').select('*');\n// after\nconst q = aql.query('transactions').select('*');","handlingStrategy":"validation","validationCode":"import { schema } from '../server/aql/schema';\nfunction tableExists(name) {\n  return Object.prototype.hasOwnProperty.call(schema, name);\n}\nif (!tableExists(tableName)) throw new Error(`unknown AQL table: ${tableName}`);","typeGuard":"function isAqlTable(name) {\n  return typeof name === 'string' && name in schema;\n}","tryCatchPattern":"import { CompileError } from '../server/aql/compiler';\ntry {\n  const { data } = await aql.runQuery(q);\n} catch (e) {\n  if (e instanceof CompileError && e.message.includes('does not exist in the schema')) {\n    logger.error({ table: e.message }, 'fix table name in query');\n  } else throw e;\n}","preventionTips":["Keep a constant/list of valid AQL table names instead of inlining strings.","Type-check queries with the table-name union type if building queries programmatically.","Grep packages/loot-core/src/server/aql/schema.ts when unsure of a table's exposed name."],"tags":["aql","query-compiler","schema","typo"],"backgroundTag":"table-not-in-schema","analyzedSha":"d4334cb6e6123f4d3bcea1ad6166608884c7e658","analyzedAt":"2026-08-29T01:02:11.213Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}