{"record":{"id":"b39755eea2ef3156","repo":"actualbudget/actual","slug":"not-found-type-with-name-name","errorCode":null,"errorMessage":"Not found: ${type} with name ${name}","messagePattern":"Not found: (.+?) with name (.+?)","errorType":"exception","errorClass":"APIError","httpStatus":null,"severity":"error","filePath":"packages/loot-core/src/server/api.ts","lineNumber":1103,"sourceCode":"\nhandlers['api/schedule-delete'] = withMutation(async function (id: string) {\n  checkFileOpen();\n  return handlers['schedule/delete']({ id });\n});\n\nhandlers['api/get-id-by-name'] = async function ({ type, name }) {\n  checkFileOpen();\n\n  const allowedTypes = ['payees', 'categories', 'schedules', 'accounts'];\n\n  if (!allowedTypes.includes(type)) {\n    throw APIError('Provide a valid type');\n  }\n\n  const { data } = await aqlQuery(q(type).filter({ name }).select('*'));\n\n  if (!data || data.length === 0) {\n    throw APIError(`Not found: ${type} with name ${name}`);\n  }\n\n  return data[0].id;\n};\n\nhandlers['api/get-server-version'] = async function () {\n  return handlers['get-server-version']();\n};\n\nexport function installAPI(serverHandlers: ServerHandlers) {\n  const merged = Object.assign({}, serverHandlers, handlers);\n  handlers = merged as Handlers;\n  return merged;\n}\n","sourceCodeStart":1085,"sourceCodeEnd":1118,"githubUrl":"https://github.com/actualbudget/actual/blob/d4334cb6e6123f4d3bcea1ad6166608884c7e658/packages/loot-core/src/server/api.ts#L1085-L1118","documentation":"After validating the type, 'api/get-id-by-name' queries the entity table filtered by exact name. If no rows come back, it throws this APIError indicating no entity of that type has that name. The filter is exact-name matching, so partial or case-differing names will not match.","triggerScenarios":"Calling getIdByName with a name that doesn't exactly match an existing entity — misspellings, trailing whitespace, different capitalization, or the entity was deleted/renamed.","commonSituations":"Hardcoded names that drifted from the actual budget data; creating the entity in a different budget file than the one queried; case sensitivity surprises ('alice' vs 'Alice').","solutions":["Verify the entity exists with that exact name in the budget (case-sensitive).","Trim whitespace and match capitalization, or look up via a case-insensitive search first.","Create the entity before resolving its id, or handle the not-found case in caller code."],"exampleFix":"// before\nconst id = await q.getIdByName('accounts', ' checking ');\n// after\nconst id = await q.getIdByName('accounts', 'Checking');","handlingStrategy":"try-catch","validationCode":"const payees = await actual.getPayees();\nconst match = payees.find(p => p.name === name);\nif (!match) throw new Error(`No payee named '${name}' in this budget`);","typeGuard":null,"tryCatchPattern":"try {\n  const id = await actual.getIdByName('payees', name);\n} catch (e) {\n  if (String(e.message).startsWith('Not found:')) {\n    // create the entity or pick a different name\n  } else throw e;\n}","preventionTips":["List entities first and match names before lookup","Trim and case-check names (matching is exact)","Don't hardcode names that can be renamed by users"],"tags":["api","not-found","lookup"],"backgroundTag":"entity-not-found","analyzedSha":"d4334cb6e6123f4d3bcea1ad6166608884c7e658","analyzedAt":"2026-08-29T01:02:11.213Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}