{"record":{"id":"0db7e30d4e5c3355","repo":"moeru-ai/airi","slug":"unknown-block-type-name-suggestion","errorCode":null,"errorMessage":"Unknown block type: ${name}${suggestion}","messagePattern":"Unknown block type: (.+?)(.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"integrations/minecraft/src/skills/world.ts","lineNumber":82,"sourceCode":"      return empty_pos[i]\n    }\n  }\n  return undefined\n}\n\nexport function getNearestBlocks(mineflayer: Mineflayer, blockTypes: string[] | string | null = null, distance: number = DEFAULT_SCAN_RADIUS, count: number = 10000): Block[] {\n  const mcData = McData.fromBot(mineflayer.bot)\n  const blockNames = blockTypes === null\n    ? mcData.getAllBlocks(['air']).map(block => block.name)\n    : (Array.isArray(blockTypes) ? blockTypes : [blockTypes])\n        .map((name) => {\n          const id = mcData.getBlockId(name)\n          if (id)\n            return name\n\n          const closest = mcData.getClosestBlockName(name)\n          const suggestion = closest ? `; did you mean ${closest}?` : ''\n          throw new Error(`Unknown block type: ${name}${suggestion}`)\n        })\n\n  const blockNameSet = new Set(blockNames)\n  const positions = mineflayer.bot.findBlocks({\n    matching: block => block && blockNameSet.has(block.name),\n    maxDistance: distance,\n    count,\n  })\n\n  return positions\n    .map((pos) => {\n      const block = mineflayer.bot.blockAt(pos)\n      const dist = pos.distanceTo(mineflayer.bot.entity.position)\n      return block ? { block, distance: dist } : null\n    })\n    .filter((item): item is { block: Block, distance: number } => item !== null)\n    .sort((a, b) => a.distance - b.distance)\n    .map(item => item.block)","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/moeru-ai/airi/blob/27111382b4a79a7e983289d6e983a06af185ed0f/integrations/minecraft/src/skills/world.ts#L64-L100","documentation":"Thrown by getNearestBlocks when, for a requested block name, McData.getBlockId(name) returns a falsy id — the name is not in the loaded minecraft-data block registry. The error includes a 'did you mean <closest>?' suffix when getClosestBlockName finds a fuzzy match. This is a plain Error and aborts the whole block-name mapping, so no scanning occurs.","triggerScenarios":"Calling getNearestBlocks/getNearestBlock with a blockType that is not a valid registry id: 'wood' instead of 'oak_log', 'ore iron' instead of 'iron_ore', a display name, or a modded block absent from vanilla data.","commonSituations":"User/LLM supplied a display name or alias; minecraft-data version does not match the server (renamed blocks between versions, e.g. old 'log' names); modded blocks not in the data set; casing or separator differences.","solutions":["Use the snake_case registry id (e.g. 'oak_log'); verify with mcData.getBlockId(name) before calling.","Leverage the suggested closest name in the error message to correct the input.","Confirm the minecraft-data version aligns with the connected server."],"exampleFix":"// before\ngetNearestBlocks(mineflayer, 'wood', 64)\n\n// after\nconst mcData = McData.fromBot(mineflayer.bot)\nif (!mcData.getBlockId('oak_log')) throw new Error('invalid block')\ngetNearestBlocks(mineflayer, 'oak_log', 64)","handlingStrategy":"type-guard","validationCode":"const mcData = McData.fromBot(mineflayer.bot)\nif (!mcData.getBlockId(blockType)) {\n  const suggestion = mcData.getClosestBlockName(blockType)\n  throw new Error(`Invalid block type: ${blockType}${suggestion ? `; did you mean ${suggestion}?` : ''}`)\n}\ngetNearestBlocks(mineflayer, blockType, distance, count)","typeGuard":"function isUnknownBlockTypeError(e: unknown): boolean {\n  return e instanceof Error && /Unknown block type:/.test(e.message)\n}","tryCatchPattern":"try {\n  return getNearestBlocks(mineflayer, blockType, distance, count)\n} catch (e) {\n  if (e instanceof Error && /Unknown block type:/.test(e.message)) {\n    // extract the 'did you mean' suggestion and retry with the corrected name\n  } else throw e\n}","preventionTips":["Pre-validate block names with mcData.getBlockId before scanning.","Use the 'did you mean' suggestion to auto-correct user input.","Keep minecraft-data version aligned with the connected server."],"tags":["minecraft","block","validation","mcdata","typo-suggestion"],"backgroundTag":null,"analyzedSha":"27111382b4a79a7e983289d6e983a06af185ed0f","analyzedAt":"2026-08-12T18:33:34.132Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}