jackwener/OpenCLI · error · CliError

FETCH_ERROR

FETCH_ERROR

Error message

Unexpected filters/peek response (missing groups)

What it means

flattenPeekGroups parses a filters/peek response and expects parsed.groups to be an array. If it is not, it throws FETCH_ERROR. Since throwIfOnesPeekBusinessError already handles 200-bodies with explicit reason/errcode/type, reaching this check usually means the endpoint returned JSON in an unexpected schema — often because the team UUID is wrong (query executed against nothing) or the deployment's peek API version differs.

Source

Thrown at clis/ones/task-helpers.js:75

    return `${id.slice(0, head)}…${id.slice(-tail)}`;
}
export function formatStamp(v) {
    if (v == null || v === '')
        return '';
    const n = Number(v);
    if (Number.isNaN(n))
        return String(v);
    const ms = n > 1e14 ? Math.floor(n / 1000) : n > 1e12 ? n : n * 1000;
    try {
        return new Date(ms).toISOString().replace('T', ' ').slice(0, 19);
    }
    catch {
        return String(v);
    }
}
export function flattenPeekGroups(parsed, limit) {
    if (!Array.isArray(parsed.groups)) {
        throw new CliError('FETCH_ERROR', 'Unexpected filters/peek response (missing groups)', 'Try -f json; check team UUID and API version.');
    }
    const groups = parsed.groups;
    const rows = [];
    for (const g of groups) {
        const entries = Array.isArray(g.entries) ? g.entries : [];
        for (const e of entries) {
            rows.push(e);
            if (rows.length >= limit)
                break;
        }
        if (rows.length >= limit)
            break;
    }
    return rows.slice(0, limit);
}
function fieldArrayFirstString(fv, fieldUuid) {
    if (!Array.isArray(fv))
        return '';

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Re-run with -f json (or -v) to inspect the raw response and see what the server actually returned.
  2. Verify ONES_TEAM_UUID matches the …/team/<team>/… segment of a working ONES URL.
  3. Check your ONES deployment's API version against the filters/peek docs; if the envelope changed, update the CLI.
  4. Confirm the plain `opencli ones tasks` (empty must) works to isolate whether the issue is your filter query or the response schema.

Example fix

// before: diagnosing with a wrong team uuid
ONES_TEAM_UUID='00000000' opencli ones tasks
// after: use the team from your ONES URL
ONES_TEAM_UUID='AbCd1234' opencli ones tasks
Defensive patterns

Strategy: type-guard

Validate before calling

// guard before consuming peek output yourself
if (!parsed || typeof parsed !== 'object' || !Array.isArray(parsed.groups)) {
  console.error('filters/peek returned no groups — verify ONES_TEAM_UUID and API version; inspect with -f json.');
}

Type guard

function isPeekPayload(p) {
  return p !== null && typeof p === 'object' && Array.isArray(p.groups) &&
    p.groups.every(g => g === null || typeof g !== 'object' || Array.isArray(g.entries) || g.entries === undefined);
}

Try / catch

try {
  const rows = await opencli.ones.tasks();
} catch (e) {
  if (e.code === 'FETCH_ERROR' && /missing groups/.test(e.message)) {
    console.error('Dump raw payload with -f json; check team UUID and ONES API version.');
  } else throw e;
}

Prevention

When it happens

Trigger: Running `opencli ones tasks` or `my-tasks` where filters/peek returns 200 JSON without a groups array — e.g. invalid/unknown team UUID, an API version whose peek envelope nests results differently, or a response like {entries: [...]} without grouping.

Common situations: Stale or incorrect ONES_TEAM_UUID after a workspace migration; self-hosted ONES version with a changed peek response format; a plugin/proxy transforming the response.

Related errors


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