{"record":{"id":"c47baa55d3fe7dc1","repo":"garrytan/gstack","slug":"invalid-type-mediatype-use-images-videos-o","errorCode":null,"errorMessage":"Invalid type: ${mediaType}. Use: images, videos, or media","messagePattern":"Invalid type: (.+?)\\. Use: images, videos, or media","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"browse/src/write-commands.ts","lineNumber":1311,"sourceCode":"        return `data:${mimeType};base64,${buffer.toString('base64')}`;\n      }\n\n      // Write to disk\n      const ext = contentType.split(';')[0].includes('/')\n        ? mimeToExt(contentType.split(';')[0].trim())\n        : '.bin';\n      const destPath = outputPath || path.join(TEMP_DIR, `browse-download-${Date.now()}${ext}`);\n      validateOutputPath(destPath);\n      fs.writeFileSync(destPath, buffer);\n      const sizeKB = Math.round(buffer.length / 1024);\n      return `Downloaded: ${destPath} (${sizeKB}KB, ${contentType.split(';')[0].trim()})`;\n    }\n\n    case 'scrape': {\n      if (args.length === 0) throw new Error('Usage: scrape <images|videos|media> [--selector sel] [--dir path] [--limit N]');\n      const mediaType = args[0];\n      if (!['images', 'videos', 'media'].includes(mediaType)) {\n        throw new Error(`Invalid type: ${mediaType}. Use: images, videos, or media`);\n      }\n\n      // Parse flags\n      const selectorIdx = args.indexOf('--selector');\n      const selector = selectorIdx >= 0 ? args[selectorIdx + 1] : undefined;\n      const dirIdx = args.indexOf('--dir');\n      const dir = dirIdx >= 0 ? args[dirIdx + 1] : path.join(TEMP_DIR, `browse-scrape-${Date.now()}`);\n      const limitIdx = args.indexOf('--limit');\n      const limit = Math.min(limitIdx >= 0 ? parseInt(args[limitIdx + 1], 10) || 50 : 50, 200);\n\n      validateOutputPath(dir);\n      fs.mkdirSync(dir, { recursive: true });\n\n      const { extractMedia } = await import('./media-extract');\n      const target = bm.getActiveFrameOrPage();\n      const filter = mediaType === 'images' ? 'images' as const\n        : mediaType === 'videos' ? 'videos' as const\n        : undefined;","sourceCodeStart":1293,"sourceCodeEnd":1329,"githubUrl":"https://github.com/garrytan/gstack/blob/94993f74012782fd94416dd44b8314f6363a13a4/browse/src/write-commands.ts#L1293-L1329","documentation":"Error \"Invalid type: ${mediaType}. Use: images, videos, or media\" thrown in garrytan/gstack.","triggerScenarios":"Thrown at browse/src/write-commands.ts:1311 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"94993f74012782fd94416dd44b8314f6363a13a4","analyzedAt":"2026-08-12T04:06:23.140Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}