jackwener/OpenCLI · error · Error

No holdings matched account filter: ${filter}

Error message

No holdings matched account filter: ${filter}

What it means

This CLI command filters a xueqiu fund-holdings snapshot by an account ID or account name substring supplied via args.account. When no holding rows match the given filter (or the snapshot itself is empty), it throws this Error instead of returning an empty result, to signal that the filter selected nothing. It is a user-input/data mismatch error, not a network failure.

Source

Thrown at clis/xueqiu/fund-holdings.js:25

    description: '获取蛋卷基金持仓明细(可用 --account 按子账户过滤)',
    domain: 'danjuanfunds.com',
    strategy: Strategy.COOKIE,
    navigateBefore: 'https://danjuanfunds.com/my-money',
    args: [
        { name: 'account', type: 'str', default: '', help: '按子账户名称或 ID 过滤' },
    ],
    columns: ['accountName', 'fdCode', 'fdName', 'marketValue', 'volume', 'dailyGain', 'holdGain', 'holdGainRate', 'marketPercent'],
    func: async (page, args) => {
        const snapshot = await fetchDanjuanAll(page);
        if (!snapshot.accounts.length) {
            throw new Error('No fund accounts found — Hint: not logged in to danjuanfunds.com?');
        }
        const filter = String(args.account ?? '').trim();
        const rows = filter
            ? snapshot.holdings.filter(h => h.accountId === filter || h.accountName.includes(filter))
            : snapshot.holdings;
        if (!rows.length) {
            throw new Error(filter ? `No holdings matched account filter: ${filter}` : 'No holdings found.');
        }
        return rows;
    },
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Run the command without --account to list all holdings and inspect the actual accountId/accountName values
  2. Copy the exact accountName (including capitalization) or accountId from the unfiltered output
  3. Trim/normalize the filter value (String(args.account).trim()) and check for typos or stale account names
  4. If the snapshot itself is empty, re-fetch/refresh the holdings snapshot from xueqiu first

Example fix

// before
node cli.js fund-holdings --account "My Fund "   // trailing space, no match
// after
node cli.js fund-holdings --account "My Fund"     // or omit --account to list all
Defensive patterns

Strategy: validation

Validate before calling

const filter = String(args.account ?? '').trim();
if (filter && !snapshot.holdings.some(h => h.accountId === filter || h.accountName.includes(filter))) {
  throw new Error(`Unknown account filter: ${filter}. Available: ` + snapshot.holdings.map(h => h.accountName).join(', '));
}

Try / catch

try {
  const rows = await listFundHoldings({ account: filter });
} catch (e) {
  if (e.message.startsWith('No holdings matched account filter')) {
    const all = await listFundHoldings({});
    console.error(`Filter '${filter}' not found. Available accounts:`, all.map(h => h.accountName));
  } else throw e;
}

Prevention

When it happens

Trigger: Running the fund-holdings command with --account set to a string that matches no holding's accountId and is not a substring of any holding's accountName (e.g. a typo'd account name, a stale account removed from xueqiu, or a renamed account).

Common situations: Typos or trailing whitespace in the account name; xueqiu renamed an account so old scripts no longer match; querying an account that exists on the site but wasn't captured in the snapshot; case-sensitivity since includes() is case-sensitive.

Related errors


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