jackwener/OpenCLI · error · ArgumentError

Either --product-id or --url is required

Error message

Either --product-id or --url is required

What it means

ArgumentError thrown by the coupang product command when neither --product-id nor --url is provided. The command needs at least one to identify which Coupang product to fetch; it then validates whichever is given via requireProductIdArg and canonicalizes the target URL.

Source

Thrown at clis/coupang/product.js:211

    name: 'product',
    access: 'read',
    description: 'Read full product detail (price, rating, seller, delivery) for a Coupang product',
    domain: 'www.coupang.com',
    strategy: Strategy.COOKIE,
    browser: true,
    args: [
        { name: 'product-id', positional: true, required: false, help: 'Coupang product ID (digits only)' },
        { name: 'url', required: false, help: 'Canonical Coupang product URL (alternative to --product-id)' },
    ],
    columns: [
        'product_id', 'title', 'price', 'original_price', 'discount_rate',
        'rating', 'review_count', 'seller', 'brand', 'rocket',
        'delivery_promise', 'image_url', 'url',
    ],
    func: async (page, kwargs) => {
        const rawProductId = kwargs['product-id'];
        if (!rawProductId && !kwargs.url) {
            throw new ArgumentError('Either --product-id or --url is required');
        }
        const productId = rawProductId
            ? requireProductIdArg(rawProductId, 'product-id')
            : requireProductIdArg(kwargs.url, '--url');
        const targetUrl = canonicalizeProductUrl(kwargs.url, productId);
        const finalUrl = targetUrl || canonicalizeProductUrl('', productId);
        await page.goto(finalUrl).catch((error) => {
            throw new CommandExecutionError(`coupang product navigation failed: ${error?.message || error}`);
        });
        await page.wait(2).catch((error) => {
            throw new CommandExecutionError(`coupang product wait failed: ${error?.message || error}`);
        });
        const result = await page.evaluate(buildProductDetailEvaluate(productId)).catch((error) => {
            throw new CommandExecutionError(`coupang product extraction failed: ${error?.message || error}`);
        });
        const loginHints = result?.loginHints ?? {};
        if (loginHints.hasLoginLink && !loginHints.hasMyCoupang) {
            throw new AuthRequiredError('coupang.com', 'Please log into Coupang in Chrome and retry.');

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Pass --product-id <id> with the numeric Coupang product ID
  2. Or pass --url <product-url> and let the CLI extract the ID from the URL
  3. Check flag spelling: must be exactly --product-id or --url (kebab-case)
  4. Verify the value is non-empty — an empty string still triggers the error

Example fix

// before
 coupang product  # ArgumentError: Either --product-id or --url is required
// after
 coupang product --url https://www.coupang.com/vp/products/12345678
Defensive patterns

Strategy: validation

Validate before calling

const productId = process.argv.find(a => a.startsWith('--product-id'))?.split('=')[1];
const url = process.argv.find(a => a.startsWith('--url'))?.split('=')[1];
if (!productId && !url) {
  throw new Error('Provide --product-id <id> or --url <product-url>');
}

Type guard

function hasProductTarget(kwargs) {
  return Boolean(kwargs && (typeof kwargs['product-id'] === 'string' && kwargs['product-id'].trim() || typeof kwargs.url === 'string' && kwargs.url.trim()));
}

Try / catch

try {
  await coupangProduct(args);
} catch (err) {
  if (err instanceof ArgumentError && /--product-id or --url/.test(err.message)) {
    console.error('Usage: coupang product --product-id <id> | --url <url>');
    process.exitCode = 2;
    return;
  }
  throw err;
}

Prevention

When it happens

Trigger: Invoking 'coupang product' with no arguments, or with misspelled flag names (e.g. --productId instead of --product-id) so kwargs contains neither key.

Common situations: Copy-pasting a command and dropping the argument; kebab-case vs camelCase flag confusion; wrapping scripts that fail to forward the argument; empty string passed as --product-id.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/6694ad76332bbed6. Report an issue: GitHub.