jackwener/OpenCLI · warning · ArgumentError

${raw}' does not look like a dianping shop id

Error message

${raw}' does not look like a dianping shop id

What it means

normalizeShopId validates the shop_id argument passed to dianping shop commands. It accepts either a bare shop id (letters, digits, underscore, dash) or a full dianping URL containing /shop/<id>, and throws ArgumentError when the resolved id fails the /^[A-Za-z0-9_-]+$/ check. This guard exists because an invalid id would silently produce garbage requests against www.dianping.com.

Source

Thrown at clis/dianping/utils.js:83

}

export function requireSearchLimit(value) {
    const raw = value == null || value === '' ? 15 : value;
    const limit = typeof raw === 'number' ? raw : Number(String(raw).trim());
    if (!Number.isInteger(limit) || limit < 1 || limit > 15) {
        throw new ArgumentError('limit must be an integer between 1 and 15 (dianping single page)');
    }
    return limit;
}

export function normalizeShopId(rawInput) {
    const raw = String(rawInput || '').trim();
    if (!raw) throw new ArgumentError('shop_id must be a non-empty string');

    const idMatch = raw.match(/\/shop\/([^?#/]+)/);
    const shopId = idMatch ? idMatch[1] : raw;
    if (!/^[A-Za-z0-9_-]+$/.test(shopId)) {
        throw new ArgumentError(`'${raw}' does not look like a dianping shop id`);
    }
    return shopId;
}

export function wrapDianpingStep(label, fn) {
    return Promise.resolve()
        .then(fn)
        .catch((err) => {
            if (err?.code) throw err;
            const message = err?.message || String(err);
            throw new CommandExecutionError(`dianping ${label} failed: ${message}`);
        });
}

/**
 * Throw the right typed error for a dianping page that didn't render data.
 * The site short-circuits HTML when bot/login checks trip — typically
 * redirects to verify.meituan.com (Yoda icon-tap captcha) or to a login

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Pass the numeric shop id from a www.dianping.com/shop/<id> URL, e.g. '1234567'.
  2. If passing a URL, make sure it contains /shop/<id>; strip query strings, trailing slashes, and surrounding whitespace/quotes first.
  3. If you have a mobile/share URL, open it and take the canonical www.dianping.com/shop/<id> id.
  4. Pre-validate the id with /^[A-Za-z0-9_-]+$/ (or extract via /\/shop\/([^?#\/]+)/) before calling.

Example fix

// before
await shopId('https://m.dianping.com/shoppage/xiaoguoxianyuluo/20083463/');
// after
await shopId('20083463'); // or a www.dianping.com/shop/20083463 URL
Defensive patterns

Strategy: validation

Validate before calling

function looksLikeShopId(input) {
  const raw = String(input || '').trim();
  const m = raw.match(/\/shop\/([^?#\/]+)/);
  return Boolean((m ? m[1] : raw) && /^[A-Za-z0-9_-]+$/.test(m ? m[1] : raw));
}
if (!looksLikeShopId(input)) throw new Error('pass a dianping shop id or a www.dianping.com/shop/<id> URL');

Type guard

function isDianpingShopId(v) {
  return typeof v === 'string' && /^[A-Za-z0-9_-]+$/.test(v.trim());
}

Try / catch

try {
  await shopId(input);
} catch (err) {
  if (err.code === 'ARGUMENT_ERROR') {
    console.error(`Invalid shop id '${input}': use the numeric id from a www.dianping.com/shop/<id> URL`);
  } else throw err;
}

Prevention

When it happens

Trigger: Calling shopId (and any shop-detail command that funnels through normalizeShopId) with input whose extracted id contains characters outside [A-Za-z0-9_-] — e.g. pasted text with spaces, CJK characters, trailing punctuation, or a URL not matching /shop/<id> such as m.dianping.com or a short link.

Common situations: Pasting a shop URL from the mobile app share sheet (different path shape), copying the shop name instead of its id, extra whitespace/quotes around the id from shell quoting, or passing a dianping search URL rather than a shop page URL.

Related errors


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