jackwener/OpenCLI · error · ArgumentError
Invalid 1688 store URL
Error message
Invalid 1688 store URL
What it means
canonicalizeStoreUrl parses an input that already looked like a URL and converts it to a canonical store URL (mobile member URL or https host). If the parsed URL's hostname does not normalize to a valid 1688 store host, it throws ArgumentError. In other words the input was a URL, but not one pointing at a 1688 store host the library understands.
Source
Thrown at clis/1688/shared.js:170
return canonicalizeStoreUrl(normalized);
}
if (normalized.endsWith('.1688.com')) {
return canonicalizeStoreUrl(`https://${normalized}`);
}
if (/^[a-z0-9-]+$/i.test(normalized)) {
return canonicalizeStoreUrl(`https://${normalized}.1688.com`);
}
throw new ArgumentError('1688 store expects a store URL or member ID', 'Example: opencli 1688 store b2b-22154705262941f196');
}
export function canonicalizeStoreUrl(input) {
const url = parse1688Url(input);
const memberId = extractMemberId(url.toString());
if (memberId) {
return `${STORE_MOBILE_URL_PREFIX}${memberId}`;
}
const host = normalizeStoreHost(url.hostname);
if (!host) {
throw new ArgumentError('Invalid 1688 store URL', 'Example: opencli 1688 store https://yinuoweierfushi.1688.com/');
}
return `https://${host}`;
}
export function canonicalizeItemUrl(input) {
const offerId = extractOfferId(input);
if (offerId) {
return `${DETAIL_URL_PREFIX}${offerId}.html`;
}
const url = parse1688UrlOrNull(input);
if (!url)
return null;
stripTrackingParams(url);
url.hash = '';
return url.toString();
}
export function canonicalizeSellerUrl(input) {
const memberId = extractMemberId(input);
if (memberId) {View on GitHub (pinned to 49907e53dc)
Solutions
- Use the store's winport URL, e.g. https://yinuoweierfushi.1688.com/ — the host must be a store subdomain of 1688.com.
- If you actually have an offer URL (detail.1688.com/offer/...), use the item command instead of store.
- Double-check the domain spelling; the host must normalize under normalizeStoreHost, so only standard 1688.com store hosts qualify.
Example fix
// before opencli 1688 store https://detail.1688.com/offer/887904326744.html // offer host, not a store host // after opencli 1688 store https://yinuoweierfushi.1688.com/
Defensive patterns
Strategy: validation
Validate before calling
function isStoreHostUrl(input) {
try {
const u = new URL(String(input));
return /(^|\.)1688\.com$/i.test(u.hostname)
&& !/^detail\./i.test(u.hostname)
&& u.hostname.split('.')[0] !== 'www';
} catch { return false; }
}
if (!isStoreHostUrl(input)) throw new Error('Provide a store winport URL like https://shop.1688.com/'); Type guard
function isStoreUrlObject(input) {
try {
const u = new URL(String(input));
return u.hostname.endsWith('.1688.com') && u.hostname !== 'detail.1688.com';
} catch { return false; }
} Try / catch
try {
const url = canonicalizeStoreUrl(input);
} catch (e) {
if (e.name === 'ArgumentError') {
console.error(`'${input}' is not a 1688 store host. Use the shop's *.1688.com winport URL.`);
} else throw e;
} Prevention
- Never feed offer (detail.1688.com) URLs to store flows — check the hostname first.
- Beware aliased/shortened domains; resolve redirects before canonicalizing.
- Keep host spelling exact: 1688.com, no typos or extra TLDs.
- Write tests covering offer URLs, www URLs, and foreign domains as negative cases.
When it happens
Trigger: resolveStoreUrl or safeCanonicalStoreUrl receives an http(s) URL whose host is not a *.1688.com store host — e.g. https://example.com, https://detail.1688.com (offer host with no store subdomain), or a URL with an unexpected subdomain pattern.
Common situations: Passing an offer/detail URL to the store command; pasting a shortened or aliased domain; using a 1688 mobile app share link with a non-standard host; typos like 1688.co or 1688.comm.
Related errors
- 1688 item expects an offer URL or offer ID
- Invalid 1688 URL
- Expected an exact BVID or bilibili.com video URL, for exampl
- Expected a trusted HTTPS bilibili.com video URL without cred
- Bilibili video URL did not contain an exact case-sensitive B
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/a37673893905274a.
Report an issue: GitHub.