jackwener/OpenCLI · error · ArgumentError
1688 store expects a store URL or member ID
Error message
1688 store expects a store URL or member ID
What it means
resolveStoreUrl normalizes a store URL or member ID into a canonical 1688 store URL. If the cleaned input is empty, it immediately throws ArgumentError with an example, because nothing was supplied at all. This is an upfront guard so the rest of the resolution logic (extractMemberId, URL parsing) only runs on non-empty input.
Source
Thrown at clis/1688/shared.js:145
}
export function buildSearchUrl(query) {
const normalized = cleanText(query);
if (!normalized) {
throw new ArgumentError('1688 search query cannot be empty', 'Example: opencli 1688 search "桌面置物架" --limit 20');
}
return `${SEARCH_URL_PREFIX}${encodeURIComponent(normalized)}`;
}
export function buildDetailUrl(input) {
const offerId = extractOfferId(input);
if (!offerId) {
throw new ArgumentError('1688 item expects an offer URL or offer ID', 'Example: opencli 1688 item 887904326744');
}
return `${DETAIL_URL_PREFIX}${offerId}.html`;
}
export function resolveStoreUrl(input) {
const normalized = cleanText(input);
if (!normalized) {
throw new ArgumentError('1688 store expects a store URL or member ID', 'Example: opencli 1688 store https://yinuoweierfushi.1688.com/');
}
const memberId = extractMemberId(normalized);
if (memberId) {
return `${STORE_MOBILE_URL_PREFIX}${memberId}`;
}
if (/^https?:\/\//i.test(normalized)) {
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);View on GitHub (pinned to 49907e53dc)
Solutions
- Supply a store URL such as https://yinuoweierfushi.1688.com/ or a member ID to the store command.
- Check that the environment variable or config entry feeding the argument is actually set (echo/print it before the call).
- Add an emptiness check on the input before calling, to fail with a clearer app-level message.
Example fix
// before
const url = resolveStoreUrl(process.env.STORE_URL); // STORE_URL unset -> empty string
// after
const input = process.env.STORE_URL;
if (!input?.trim()) throw new Error('STORE_URL is required, e.g. https://yourshop.1688.com/');
const url = resolveStoreUrl(input); Defensive patterns
Strategy: validation
Validate before calling
function requireStoreInput(input) {
if (typeof input !== 'string' || !input.trim()) {
throw new Error('1688 store input required: a store URL or member ID (e.g. https://shop.1688.com/)');
}
return input.trim();
}
resolveStoreUrl(requireStoreInput(process.env.STORE_URL)); Type guard
function hasStoreInput(input) {
return typeof input === 'string' && input.trim().length > 0;
} Try / catch
try {
const url = resolveStoreUrl(input);
} catch (e) {
if (e.name === 'ArgumentError') {
console.error('Store URL/member ID missing or empty — check the --store flag or STORE_URL env var.');
} else throw e;
} Prevention
- Echo the argument value (length + prefix) in logs before invoking store commands.
- Set required values via explicit flags rather than relying on possibly-unset env vars.
- Fail fast at CLI arg-parse time when the store argument is absent.
- Keep a known-good example store URL in your integration tests.
When it happens
Trigger: Calling resolveStoreUrl (via resolvedUrl) with '', ' ', null, or undefined — e.g. a CLI flag not provided, an env/config variable unset, or an upstream field that failed to populate.
Common situations: Missing OPENCLI config/env value for the store URL; a script variable that an earlier step failed to set; copy-paste that dropped the whole value; calling the 1688 store command without its URL argument.
Related errors
- ${commandName} prompt cannot be empty
- flathub ${label} cannot be empty
- text must not be empty
- <train-no> must not be empty
- <train-no> "${trainNo}" does not look like a 12306 internal
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/1f11079efe56194b.
Report an issue: GitHub.