{"record":{"id":"f02709265c4f234c","repo":"moeru-ai/airi","slug":"item-not-found-f02709","errorCode":"ITEM_NOT_FOUND","errorMessage":"You do not have any ${name} to eat","messagePattern":"You do not have any (.+?) to eat","errorType":"error_code","errorClass":"ActionError","httpStatus":null,"severity":"error","filePath":"integrations/minecraft/src/skills/inventory.ts","lineNumber":142,"sourceCode":"      }\n    }\n  })\n  return true\n}\n\n/**\n * Consume (eat/drink) an item from the bot's inventory.\n * @param mineflayer The mineflayer instance.\n * @param itemName The name of the item to consume.\n * @throws {ActionError} When the item is not found in inventory.\n */\nexport async function consume(mineflayer: Mineflayer, itemName = ''): Promise<void> {\n  const item = mineflayer.bot.inventory.items().find(item => itemName ? item.name === itemName : item.name.includes('food'))\n\n  if (!item) {\n    const name = itemName || 'food'\n    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  }","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/moeru-ai/airi/blob/27111382b4a79a7e983289d6e983a06af185ed0f/integrations/minecraft/src/skills/inventory.ts#L124-L160","documentation":"Thrown by consume() when no inventory item matches: if itemName is given, an exact item.name === itemName match; if itemName is empty/default, any item whose name includes 'food'. It is an ActionError with code ITEM_NOT_FOUND and context { item: name }. The function logs to the player before throwing.","triggerScenarios":"Calling consume(mineflayer, 'bread') with no bread in inventory; calling consume(mineflayer) (no name) when no inventory item name contains the substring 'food'; passing a non-food item name that the bot does not carry.","commonSituations":"Bot's inventory was emptied by a prior discard/give; user asked to eat an item the bot never collected; minecraft item id for food does not literally contain 'food' (e.g. 'bread', 'cooked_beef') so the no-argument fallback never matches vanilla food.","solutions":["Pass the exact item id of a food item present in inventory (e.g. 'cooked_beef'), verified via inventory.items().","Gather food first (hunt/cook/farm) before calling consume.","Do not rely on the no-argument form for vanilla food — pass an explicit name."],"exampleFix":"// before\nawait consume(mineflayer) // relies on name.includes('food')\n\n// after\nconst food = mineflayer.bot.inventory.items().find(i => i.name.includes('beef') || i.name === 'bread')\nif (!food) throw new Error('No food available')\nawait consume(mineflayer, food.name)","handlingStrategy":"validation","validationCode":"const items = mineflayer.bot.inventory.items()\nconst target = itemName ? items.find(i => i.name === itemName) : items.find(i => i.name.includes('food'))\nif (!target) throw new Error(`No ${itemName || 'food'} in inventory`)\nawait consume(mineflayer, itemName)","typeGuard":"import { ActionError } from '../utils/errors'\nfunction isNoFoodError(e: unknown): boolean {\n  return e instanceof ActionError && e.code === 'ITEM_NOT_FOUND' && /to eat/.test(e.message)\n}","tryCatchPattern":"try {\n  await consume(mineflayer, itemName)\n} catch (e) {\n  if (e instanceof ActionError && e.code === 'ITEM_NOT_FOUND') {\n    // gather or cook food, then retry with an explicit name\n  } else throw e\n}","preventionTips":["Pass an explicit food item id present in inventory rather than relying on the 'food' substring fallback.","Keep a food reserve in inventory during long sessions.","Verify the item id with inventory.items() before consuming."],"tags":["minecraft","inventory","food","consume","actionerror"],"backgroundTag":null,"analyzedSha":"27111382b4a79a7e983289d6e983a06af185ed0f","analyzedAt":"2026-08-12T18:33:34.132Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}