{"record":{"id":"e51c880ed5429a0f","repo":"actualbudget/actual","slug":"unsupported-type-of-expression","errorCode":null,"errorMessage":"Unsupported type of expression: ","messagePattern":"Unsupported type of expression: ","errorType":"exception","errorClass":"CompileError","httpStatus":null,"severity":"error","filePath":"packages/loot-core/src/server/aql/compiler.ts","lineNumber":481,"sourceCode":"  } else if (value === null) {\n    return typed('NULL', 'null', { literal: true });\n  } else if (value instanceof Date) {\n    return typed(nativeDateToInt(value), 'date', { literal: true });\n  } else if (typeof value === 'string') {\n    // Allow user to escape $, and quote the string to make it a\n    // string literal in the output\n    value = value.replace(/\\\\\\$/g, '$');\n    return typed(value, 'string', { literal: true });\n  } else if (typeof value === 'boolean') {\n    return typed(value ? 1 : 0, 'boolean', { literal: true });\n  } else if (typeof value === 'number') {\n    return typed(value, Number.isInteger(value) ? 'integer' : 'float', {\n      literal: true,\n    });\n  } else if (Array.isArray(value)) {\n    return typed(value, 'array', { literal: true });\n  } else {\n    throw new CompileError(\n      'Unsupported type of expression: ' + JSON.stringify(value),\n    );\n  }\n}\n\nconst compileExpr = saveStack('expr', (state, expr) => {\n  if (typeof expr === 'string') {\n    // Field reference\n    if (expr[0] === '$') {\n      const fieldRef = expr === '$' ? state.implicitField : expr.slice(1);\n\n      if (fieldRef == null || fieldRef === '') {\n        throw new CompileError('Invalid field reference: ' + expr);\n      }\n\n      return transformField(state, fieldRef);\n    }\n","sourceCodeStart":463,"sourceCodeEnd":499,"githubUrl":"https://github.com/actualbudget/actual/blob/d4334cb6e6123f4d3bcea1ad6166608884c7e658/packages/loot-core/src/server/aql/compiler.ts#L463-L499","documentation":"compileLiteral accepts only null, Date, string, boolean, number, and array literals. Anything else (plain objects, functions, symbols, BigInt) throws 'Unsupported type of expression: ' + JSON.stringify(value). The compiler has no SQL representation for it.","triggerScenarios":"Passing a nested plain object as a literal value (e.g. { date: { gte: '2024-01' } } in a position expecting a raw literal rather than an operator expression); passing a function or class instance; passing Symbol/BigInt.","commonSituations":"Mixing up operator-object syntax ({ $gte: ... }) with raw literal positions; passing Date-like wrappers (dayjs/moment objects) that aren't real Date instances; serializing errors into query values.","solutions":["Convert the value to a supported literal: primitive string/number/boolean, null, native Date, or array","Call .toDate() on dayjs/moment wrappers before passing them","Use the proper operator-expression syntax ($gte etc.) instead of a bare object where a literal is expected","Stringify/serialize custom objects yourself before embedding them"],"exampleFix":"// before\nq.filter({ date: dayjs('2024-01-15') })\n// after\nq.filter({ date: dayjs('2024-01-15').toDate() })","handlingStrategy":"type-guard","validationCode":"const SUPPORTED = ['string','number','boolean'];\nfunction assertLiteral(v) {\n  if (v == null || v instanceof Date || Array.isArray(v) || SUPPORTED.includes(typeof v)) return;\n  throw new Error('Unsupported query literal: ' + typeof v);\n}","typeGuard":"function isSupportedLiteral(v) {\n  return v == null || v instanceof Date || Array.isArray(v) ||\n    ['string','number','boolean'].includes(typeof v);\n}","tryCatchPattern":"try {\n  runQuery(query);\n} catch (e) {\n  if (/Unsupported type of expression/.test(e.message)) {\n    console.error('Convert the value to a supported literal (primitive, Date, array, null)');\n  }\n  throw e;\n}","preventionTips":["Call .toDate() on dayjs/moment objects before embedding","Use operator syntax ($gte, etc.) for structured comparisons, not bare objects","Never embed functions, class instances, or Symbols in queries"],"tags":["aql","query-compiler","unsupported-type","literal-validation"],"backgroundTag":"unsupported-literal-type","analyzedSha":"d4334cb6e6123f4d3bcea1ad6166608884c7e658","analyzedAt":"2026-08-29T01:02:11.213Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}