{"record":{"id":"ee9b93474e520c46","repo":"moeru-ai/airi","slug":"unknown-ee9b93","errorCode":"UNKNOWN","errorMessage":"Invalid item name: ${itemName}","messagePattern":"Invalid item name: (.+?)","errorType":"error_code","errorClass":"ActionError","httpStatus":null,"severity":"error","filePath":"integrations/minecraft/src/skills/crafting.ts","lineNumber":35,"sourceCode":"import { goToNearestBlock, goToPosition, moveAway } from './movement'\nimport { getInventoryCounts, getNearestBlock, getNearestFreeSpace } from './world'\n\nconst logger = useLogger()\n\nexport async function craftRecipe(\n  mineflayer: Mineflayer,\n  incomingItemName: string,\n  num = 1,\n): Promise<boolean> {\n  let itemName = incomingItemName.replaceAll(' ', '_').toLowerCase()\n\n  if (itemName.endsWith('plank'))\n    itemName += 's' // Correct common mistakes\n\n  const mcData = McData.fromBot(mineflayer.bot)\n  const itemId = mcData.getItemId(itemName)\n  if (!itemId) {\n    throw new ActionError('UNKNOWN', `Invalid item name: ${itemName}`)\n  }\n\n  // Helper function to attempt crafting\n  async function attemptCraft(\n    recipes: Recipe[] | null,\n    craftingTable: Block | null = null,\n  ): Promise<boolean> {\n    if (recipes && recipes.length > 0) {\n      const recipe = recipes[0]\n      try {\n        await mineflayer.bot.craft(recipe, num, craftingTable ?? undefined)\n        logger.log(\n          `Successfully crafted ${num} ${itemName}${craftingTable ? ' using crafting table' : ''\n          }.`,\n        )\n        return true\n      }\n      catch (err) {","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/moeru-ai/airi/blob/27111382b4a79a7e983289d6e983a06af185ed0f/integrations/minecraft/src/skills/crafting.ts#L17-L53","documentation":"Thrown by craftRecipe when McData.getItemId(itemName) returns a falsy id, meaning the normalized name is not a registered Minecraft item in the loaded version's item registry. The library normalizes input (lowercase, spaces to underscores, appends 's' to '*plank') but if the result still is not a real item id, it aborts before any recipe lookup. Coded UNKNOWN because the item itself is unrecognized.","triggerScenarios":"Passing a display name that does not map to an id ('pickaxe' alone is not valid — must be 'wooden_pickaxe' etc.); a modded item not in the vanilla registry; a typo ('wooden_plak' ); a version mismatch (an item added in 1.20 when the bot runs 1.16); passing a block name like 'oak_log' that is valid as an item but using a wrong alias.","commonSituations":"LLM hallucinates a item name; modded server with custom items the registry does not know; bot connected with wrong protocol version; user gave a friendly name ('stairs') that needs a material prefix ('oak_stairs').","solutions":["Look up the canonical id first: const mcData = McData.fromBot(mineflayer.bot); if (!mcData.getItemId(name)) ask the planner to disambiguate.","Match against the registry and suggest the closest valid id (Levenshtein on mcData.itemsArray).","Ensure the bot's minecraft-data version matches the server (mineflayer-bot protocol / mcData version).","For modded items, extend the registry or refuse with a user-facing 'unsupported item' message."],"exampleFix":"// before\ncraftRecipe(mineflayer, 'plak', 4)\n\n// after\nconst mcData = McData.fromBot(mineflayer.bot)\nconst name = 'plak'.replaceAll(' ', '_').toLowerCase()\nif (!mcData.getItemId(name)) {\n  throw new Error(`Unknown item '${name}'. Check spelling and Minecraft version.`)\n}\nawait craftRecipe(mineflayer, name, 4)","handlingStrategy":"validation","validationCode":"function isValidItem(mineflayer: Mineflayer, name: string): boolean {\n  const mcData = McData.fromBot(mineflayer.bot)\n  const normalized = name.replaceAll(' ', '_').toLowerCase()\n  return !!mcData.getItemId(normalized)\n}\nif (!isValidItem(mineflayer, userInput)) {\n  throw new Error(`'${userInput}' is not a known item for MC ${mineflayer.bot.game.version}`)\n}","typeGuard":null,"tryCatchPattern":"try {\n  await craftRecipe(mineflayer, userInput, 1)\n} catch (e) {\n  if (e instanceof ActionError && e.code === 'UNKNOWN' && e.message.startsWith('Invalid item name')) {\n    // prompt user/planner for a corrected name\n  } else throw e\n}","preventionTips":["Normalize item names (lowercase, underscores) before lookup.","Cross-check the item against the loaded MC version (mcData.itemsByName).","Maintain an alias map for common display names ('wooden pickaxe' -> 'wooden_pickaxe').","For modded items, ensure the registry plugin is loaded before lookup."],"tags":["minecraft","item-registry","validation","crafting"],"backgroundTag":null,"analyzedSha":"27111382b4a79a7e983289d6e983a06af185ed0f","analyzedAt":"2026-08-12T18:33:34.132Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}