garrytan/gstack · error

Invalid type: ${mediaType}. Use: images, videos, or media

Error message

Invalid type: ${mediaType}. Use: images, videos, or media

What it means

Error "Invalid type: ${mediaType}. Use: images, videos, or media" thrown in garrytan/gstack.

Source

Thrown at browse/src/write-commands.ts:1311

        return `data:${mimeType};base64,${buffer.toString('base64')}`;
      }

      // Write to disk
      const ext = contentType.split(';')[0].includes('/')
        ? mimeToExt(contentType.split(';')[0].trim())
        : '.bin';
      const destPath = outputPath || path.join(TEMP_DIR, `browse-download-${Date.now()}${ext}`);
      validateOutputPath(destPath);
      fs.writeFileSync(destPath, buffer);
      const sizeKB = Math.round(buffer.length / 1024);
      return `Downloaded: ${destPath} (${sizeKB}KB, ${contentType.split(';')[0].trim()})`;
    }

    case 'scrape': {
      if (args.length === 0) throw new Error('Usage: scrape <images|videos|media> [--selector sel] [--dir path] [--limit N]');
      const mediaType = args[0];
      if (!['images', 'videos', 'media'].includes(mediaType)) {
        throw new Error(`Invalid type: ${mediaType}. Use: images, videos, or media`);
      }

      // Parse flags
      const selectorIdx = args.indexOf('--selector');
      const selector = selectorIdx >= 0 ? args[selectorIdx + 1] : undefined;
      const dirIdx = args.indexOf('--dir');
      const dir = dirIdx >= 0 ? args[dirIdx + 1] : path.join(TEMP_DIR, `browse-scrape-${Date.now()}`);
      const limitIdx = args.indexOf('--limit');
      const limit = Math.min(limitIdx >= 0 ? parseInt(args[limitIdx + 1], 10) || 50 : 50, 200);

      validateOutputPath(dir);
      fs.mkdirSync(dir, { recursive: true });

      const { extractMedia } = await import('./media-extract');
      const target = bm.getActiveFrameOrPage();
      const filter = mediaType === 'images' ? 'images' as const
        : mediaType === 'videos' ? 'videos' as const
        : undefined;

View on GitHub (pinned to 94993f7401)

When it happens

Trigger: Thrown at browse/src/write-commands.ts:1311 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of garrytan/gstack@94993f7401 (2026-08-12). Data as JSON: /api/errors/c47baa55d3fe7dc1. Report an issue: GitHub.