{"record":{"id":"4112fb942fc91c11","repo":"moeru-ai/airi","slug":"failed-to-ensure-mediapipe-vision-task-asset-for","errorCode":null,"errorMessage":"Failed to ensure MediaPipe vision task asset for ${key}: missing or empty file at ${outputPath}","messagePattern":"Failed to ensure MediaPipe vision task asset for (.+?): missing or empty file at (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/model-driver-mediapipe/tasks/prepare-tasks.ts","lineNumber":91,"sourceCode":"  }\n  catch (error) {\n    throw new Error(`Failed to download MediaPipe vision task asset for ${key} after ${attempt} attempts`, {\n      cause: error,\n    })\n  }\n}\n\nawait fs.mkdir(assetsRoot, { recursive: true })\n\nfor (const { key, source, outputPath } of taskTargets) {\n  if (await isUsableFile(outputPath)) {\n    console.log(`MediaPipe vision task asset for ${key} already exists at ${outputPath}, skipping download.`)\n    continue\n  }\n  await downloadAsset(key, source, outputPath)\n\n  if (!await isUsableFile(outputPath))\n    throw new Error(`Failed to ensure MediaPipe vision task asset for ${key}: missing or empty file at ${outputPath}`)\n}\n\nawait fs.mkdir(wasmOutputDir, { recursive: true })\nawait fs.cp(wasmSourceDir, wasmOutputDir, { recursive: true, force: true })\n\nconst wasmEntries = await fs.readdir(wasmOutputDir)\nif (!wasmEntries.length)\n  throw new Error(`Failed to ensure MediaPipe WASM assets: ${wasmOutputDir} is empty`)\n\nconsole.log('All MediaPipe vision task assets are prepared.')\n","sourceCodeStart":73,"sourceCodeEnd":102,"githubUrl":"https://github.com/moeru-ai/airi/blob/677329427f32468c74b17f3ec47eeca4e05bec65/packages/model-driver-mediapipe/tasks/prepare-tasks.ts#L73-L102","documentation":"After downloadAsset() 'succeeds' (or is skipped because a file existed), prepare-tasks.ts re-validates the output with isUsableFile(outputPath). If the file is missing or zero bytes (a truncated/interrupted download or a pre-existing empty placeholder), it throws this error naming the key and path. It exists to prevent a half-downloaded model from silently breaking FaceLandmarker/PoseLandmarker/HandLandmarker creation at runtime.","triggerScenarios":"A previous run was killed mid-download leaving an empty file that later runs' isUsableFile skip-check would have caught — but here the fresh download itself ends with an empty/absent file (server returned an empty body, disk full, or the write was interrupted). Also possible when a proxy or captive portal returns an empty 200.","commonSituations":"Disk-full CI runners; captive Wi-Fi portals returning empty responses; interrupted first download that left a 0-byte file which the skip branch then short-circuits on the next run (remove it); antivirus quarantining the file immediately after write.","solutions":["Delete the empty/partial file at the reported outputPath and re-run the prepare task with a healthy network.","Check disk space on the target volume — truncated writes often come from ENOSPC.","Verify the URL returns real bytes: curl -fL <source> -o <outputPath> manually, then re-run the script so the skip branch validates it.","On CI, cache the assets directory so downloads rarely re-run."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"import { stat } from 'node:fs/promises'\nasync function isUsableFile(path: string): Promise<boolean> {\n  try {\n    return (await stat(path)).size > 0\n  } catch {\n    return false\n  }\n}\n// run before the build task; delete empties so the script re-downloads\nif (await isUsableFile(outputPath) === false) await rm(outputPath).catch(() => {})","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Delete zero-byte files under the assets directory before re-running the prepare task — the skip branch treats empty files as absent and re-downloads, but a stale empty file from an interrupted run is the usual culprit.","Monitor disk space on CI; truncated writes are typically ENOSPC.","Verify downloads manually with curl -fL when a proxy is suspected of returning empty 200s."],"tags":["mediapipe","build","assets","download","filesystem"],"backgroundTag":"empty-or-corrupt-download","analyzedSha":"677329427f32468c74b17f3ec47eeca4e05bec65","analyzedAt":"2026-08-18T17:29:58.153Z","contentChangedAt":"2026-08-18T17:29:58.153Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}