{"record":{"id":"51f028ba3db310ba","repo":"actualbudget/actual","slug":"parameter-name-not-provided-to-query","errorCode":null,"errorMessage":"Parameter ${name} not provided to query","messagePattern":"Parameter (.+?) not provided to query","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/loot-core/src/server/aql/exec.ts","lineNumber":74,"sourceCode":"type AqlQueryParamName = string;\ntype AqlQueryParamValue = unknown;\nexport type AqlQueryParams = Record<AqlQueryParamName, AqlQueryParamValue>;\n\nexport type RunCompiledAqlQueryOptions = {\n  params?: AqlQueryParams;\n  executors?: Record<string, AqlQueryExecutor>;\n};\n\nexport async function runCompiledAqlQuery(\n  queryState: QueryState,\n  sqlPieces: SqlPieces,\n  compilerState: CompilerState,\n  { params = {}, executors = {} }: RunCompiledAqlQueryOptions = {},\n) {\n  const paramArray = compilerState.namedParameters.map(param => {\n    const name = param.paramName;\n    if (params[name] === undefined) {\n      throw new Error(`Parameter ${name} not provided to query`);\n    }\n    return convertInputType(params[name], param.paramType);\n  });\n\n  let data: Record<string, unknown>[] = [];\n  if (executors[compilerState.implicitTableName]) {\n    data = await executors[compilerState.implicitTableName](\n      compilerState,\n      queryState,\n      sqlPieces,\n      paramArray,\n      compilerState.outputTypes,\n    );\n  } else {\n    data = await execQuery(\n      queryState,\n      compilerState,\n      sqlPieces,","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/actualbudget/actual/blob/d4334cb6e6123f4d3bcea1ad6166608884c7e658/packages/loot-core/src/server/aql/exec.ts#L56-L92","documentation":"runCompiledAqlQuery maps the query's namedParameters (collected during compilation from `$param`-style references) to the user-supplied `params` object. If any named parameter has no corresponding entry in `params` (strictly `undefined`), a plain Error is thrown because the SQL statement cannot be safely bound.","triggerScenarios":"Executing an AQL query containing `{$param: 'minDate'}` (or filters using `:minDate` placeholders) via `aqlQuery(q, {params: {...}})` without supplying `minDate`, or supplying it under a misspelled key.","commonSituations":"Renaming a parameter in the query but not in the params object, conditionally omitting a param that the query still references, or passing params through an API layer that drops undefined keys.","solutions":["Add the missing key to the params object with the exact name the query references.","Log/inspect `compilerState.namedParameters` to see which parameter names the compiled query expects.","Remove the `{$param: ...}` reference from the query if the value is no longer needed, or give it a default before calling."],"exampleFix":"// before\nawait aqlQuery(q('transactions').filter({date: {$gte: {$param: '$minDate'}}}), {})\n// after\nawait aqlQuery(q('transactions').filter({date: {$gte: {$param: '$minDate'}}}), { params: { minDate: '2024-01-01' } })","handlingStrategy":"try-catch","validationCode":"function assertParamsProvided(query, params) {\n  for (const name of collectParamNames(query)) {\n    if (params?.[name] === undefined) throw new Error(`Parameter ${name} not provided to query`);\n  }\n}","typeGuard":"const hasAllParams = (names, params) => names.every(n => params && params[n] !== undefined);","tryCatchPattern":"try {\n  await runCompiledAqlQuery(compiled, { params });\n} catch (e) {\n  if (/Parameter .* not provided to query/.test(e.message)) {\n    console.error('Missing query params; expected:', compiled.state.namedParameters.map(p => p.paramName));\n  }\n  throw e;\n}","preventionTips":["Keep parameter names in a shared constant used by both query and params object.","Validate params against namedParameters before execution.","Avoid conditionally deleting keys from a params object still referenced by the query.","Give required params explicit defaults at call sites instead of undefined."],"tags":["aql","query-execution","missing-parameter"],"backgroundTag":"missing-query-parameter","analyzedSha":"d4334cb6e6123f4d3bcea1ad6166608884c7e658","analyzedAt":"2026-08-29T01:02:11.213Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}