{"record":{"id":"db2d41ffd251d2bc","repo":"moeru-ai/airi","slug":"target-not-found-db2d41","errorCode":"TARGET_NOT_FOUND","errorMessage":"Could not find ${username}","messagePattern":"Could not find (.+?)","errorType":"error_code","errorClass":"ActionError","httpStatus":null,"severity":"error","filePath":"integrations/minecraft/src/skills/inventory.ts","lineNumber":159,"sourceCode":"    log(mineflayer, `You do not have any ${name} to eat.`)\n    throw new ActionError('ITEM_NOT_FOUND', `You do not have any ${name} to eat`, { item: name })\n  }\n\n  await mineflayer.bot.equip(item, 'hand')\n  await mineflayer.bot.consume()\n  log(mineflayer, `Consumed ${item.name}.`)\n}\n\nexport async function giveToPlayer(\n  mineflayer: Mineflayer,\n  itemType: string,\n  username: string,\n  num = 1,\n): Promise<void> {\n  const player = mineflayer.bot.players[username]?.entity\n  if (!player) {\n    log(mineflayer, `Could not find ${username}.`)\n    throw new ActionError('TARGET_NOT_FOUND', `Could not find ${username}`, { target: username })\n  }\n\n  // Move to player position\n  await goToPlayer(mineflayer, username, 3)\n\n  // Look at player before dropping items\n  await mineflayer.bot.lookAt(player.position)\n\n  // Drop items and wait for collection\n  await dropItemsAndWaitForCollection(mineflayer, itemType, username, num)\n}\n\nasync function dropItemsAndWaitForCollection(\n  mineflayer: Mineflayer,\n  itemType: string,\n  username: string,\n  num: number,\n): Promise<void> {","sourceCodeStart":141,"sourceCodeEnd":177,"githubUrl":"https://github.com/moeru-ai/airi/blob/27111382b4a79a7e983289d6e983a06af185ed0f/integrations/minecraft/src/skills/inventory.ts#L141-L177","documentation":"Thrown by giveToPlayer when mineflayer.bot_players[username]?.entity is falsy — the named player exists in bot_players but has no loaded entity (or is not present at all). It is an ActionError with code TARGET_NOT_FOUND and context { target: username }. A missing entity means the player is out of render distance, despawned, or offline; their entry may still exist without an entity.","triggerScenarios":"Calling giveToPlayer(mineflayer, itemType, username, num) where the username is not in bot_players, or is present but bot_players[username].entity is undefined (player out of render-distance / logged off / in another dimension).","commonSituations":"Recipient walked out of the bot's render distance; recipient logged off; typo in username; case mismatch (Minecraft usernames are case-sensitive in this lookup); player is in another dimension.","solutions":["Confirm the player is online and within render distance before calling; have them stand near the bot.","Use the exact case-correct username (check Object.keys(mineflayer.bot_players)).","Ask the recipient to approach the bot, then retry."],"exampleFix":"// before\nawait giveToPlayer(mineflayer, 'diamond', 'Steve', 1)\n\n// after\nconst target = mineflayer.bot_players['Steve']\nif (!target?.entity) throw new Error('Steve is not nearby')\nawait giveToPlayer(mineflayer, 'diamond', 'Steve', 1)","handlingStrategy":"validation","validationCode":"const target = mineflayer.bot_players[username]?.entity\nif (!target) throw new Error(`${username} is not nearby / has no entity`)\nawait giveToPlayer(mineflayer, itemType, username, num)","typeGuard":"import { ActionError } from '../utils/errors'\nfunction isPlayerNotFoundError(e: unknown): boolean {\n  return e instanceof ActionError && e.code === 'TARGET_NOT_FOUND'\n}","tryCatchPattern":"try {\n  await giveToPlayer(mineflayer, itemType, username, num)\n} catch (e) {\n  if (e instanceof ActionError && e.code === 'TARGET_NOT_FOUND') {\n    // ask the recipient to approach, then retry\n  } else throw e\n}","preventionTips":["Confirm the recipient is online and within render distance before calling.","Use the case-correct username from Object.keys(mineflayer.bot_players).","Have the recipient stand near the bot to ensure a loaded entity."],"tags":["minecraft","player","target","give","actionerror"],"backgroundTag":null,"analyzedSha":"27111382b4a79a7e983289d6e983a06af185ed0f","analyzedAt":"2026-08-12T18:33:34.132Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}