{"record":{"id":"65787c2c2a74975d","repo":"moeru-ai/airi","slug":"unknown-65787c","errorCode":"UNKNOWN","errorMessage":"Invalid position to break block at","messagePattern":"Invalid position to break block at","errorType":"exception","errorClass":"ActionError","httpStatus":null,"severity":"error","filePath":"integrations/minecraft/src/skills/actions/world-interactions.ts","lineNumber":220,"sourceCode":"  }\n}\n\n/**\n * Break a block at the given position.\n * @param mineflayer The mineflayer instance.\n * @param x The x coordinate.\n * @param y The y coordinate.\n * @param z The z coordinate.\n * @throws {ActionError} When the block is unbreakable or missing tools.\n */\nexport async function breakBlockAt(\n  mineflayer: Mineflayer,\n  x: number,\n  y: number,\n  z: number,\n): Promise<void> {\n  if (x == null || y == null || z == null) {\n    throw new ActionError('UNKNOWN', 'Invalid position to break block at')\n  }\n\n  // Calculate the block position by rounding down the coordinates\n  const blockPos = new Vec3(Math.floor(x), Math.floor(y), Math.floor(z))\n  logger.log(`Attempting to break block at ${blockPos}`)\n\n  // Log bot position\n  const botPos = mineflayer.bot.entity.position\n  logger.log(`Bot position: ${botPos.x.toFixed(1)}, ${botPos.y.toFixed(1)}, ${botPos.z.toFixed(1)}`)\n\n  // Calculate the actual block under the bot's feet\n  const feetPos = new Vec3(Math.floor(botPos.x), Math.floor(botPos.y - 1), Math.floor(botPos.z))\n  logger.log(`Actual block under feet: ${feetPos}`)\n\n  // Use the provided position directly\n  const targetPos = blockPos\n\n  const block = mineflayer.bot.blockAt(targetPos)","sourceCodeStart":202,"sourceCodeEnd":238,"githubUrl":"https://github.com/moeru-ai/airi/blob/27111382b4a79a7e983289d6e983a06af185ed0f/integrations/minecraft/src/skills/actions/world-interactions.ts#L202-L238","documentation":"Thrown by breakBlockAt (world-interactions.ts:220) with code UNKNOWN when any of x, y, or z is null (compared with ==, so undefined also matches). This is a defensive precondition check before any block math runs; no mineflayer state is touched. No context payload.","triggerScenarios":"Call breakBlockAt with null/undefined coordinates: an unset variable, a missing field from a parsed schematic, or an optional parameter that was not provided. The == null check deliberately catches both null and undefined.","commonSituations":"Caller forgot to pass one coordinate, schematic parser returned undefined for a missing axis, position came from an object whose property was renamed, or a default-parameter chain resolved to undefined.","solutions":["Validate coordinates are numbers before calling: typeof x === 'number' && Number.isFinite(x).","Default missing axes to the bot's current position (bot.entity.position) when sensible.","Add a TypeScript signature that rejects undefined (remove optionality) so the call site fails to compile.","Log the offending coordinate in the caller to catch the source of the null."],"exampleFix":"// before\nawait breakBlockAt(bot, pos.x, pos.y /* z missing */) // throws UNKNOWN\n\n// after\nif (pos.x == null || pos.y == null || pos.z == null) throw new Error('bad pos')\nawait breakBlockAt(bot, pos.x, pos.y, pos.z)","handlingStrategy":"validation","validationCode":"if (x == null || y == null || z == null || !Number.isFinite(x) || !Number.isFinite(y) || !Number.isFinite(z)) {\n  throw new TypeError(`invalid coordinates: ${x}, ${y}, ${z}`)\n}\nawait breakBlockAt(mineflayer, x, y, z)","typeGuard":"const areValidCoords = (x: unknown, y: unknown, z: unknown): boolean =>\n  typeof x === 'number' && typeof y === 'number' && typeof z === 'number'\n  && Number.isFinite(x) && Number.isFinite(y) && Number.isFinite(z)","tryCatchPattern":"try {\n  await breakBlockAt(mineflayer, x, y, z)\n} catch (e) {\n  if (e instanceof ActionError && e.code === 'UNKNOWN' && e.message.includes('Invalid position')) {\n    // fix or default the coordinates, then retry\n  } else throw e\n}","preventionTips":["Type the caller's coordinates as `number` (not `number | undefined`) so TypeScript rejects missing args.","Validate schematic-parsed positions with Number.isFinite before any block action.","Default optional axes to the bot's current position when sensible."],"tags":["minecraft","validation","input-validation","mineflayer"],"backgroundTag":null,"analyzedSha":"27111382b4a79a7e983289d6e983a06af185ed0f","analyzedAt":"2026-08-12T18:33:34.132Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}