{"record":{"id":"39241d9e5b60275f","repo":"jackwener/OpenCLI","slug":"fetch-error-39241d","errorCode":"FETCH_ERROR","errorMessage":"Unexpected filters/peek response (missing groups)","messagePattern":"Unexpected filters/peek response \\(missing groups\\)","errorType":"error_code","errorClass":"CliError","httpStatus":null,"severity":"error","filePath":"clis/ones/task-helpers.js","lineNumber":75,"sourceCode":"    return `${id.slice(0, head)}…${id.slice(-tail)}`;\n}\nexport function formatStamp(v) {\n    if (v == null || v === '')\n        return '';\n    const n = Number(v);\n    if (Number.isNaN(n))\n        return String(v);\n    const ms = n > 1e14 ? Math.floor(n / 1000) : n > 1e12 ? n : n * 1000;\n    try {\n        return new Date(ms).toISOString().replace('T', ' ').slice(0, 19);\n    }\n    catch {\n        return String(v);\n    }\n}\nexport function flattenPeekGroups(parsed, limit) {\n    if (!Array.isArray(parsed.groups)) {\n        throw new CliError('FETCH_ERROR', 'Unexpected filters/peek response (missing groups)', 'Try -f json; check team UUID and API version.');\n    }\n    const groups = parsed.groups;\n    const rows = [];\n    for (const g of groups) {\n        const entries = Array.isArray(g.entries) ? g.entries : [];\n        for (const e of entries) {\n            rows.push(e);\n            if (rows.length >= limit)\n                break;\n        }\n        if (rows.length >= limit)\n            break;\n    }\n    return rows.slice(0, limit);\n}\nfunction fieldArrayFirstString(fv, fieldUuid) {\n    if (!Array.isArray(fv))\n        return '';","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/ones/task-helpers.js#L57-L93","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Re-run with -f json (or -v) to inspect the raw response and see what the server actually returned.","Verify ONES_TEAM_UUID matches the …/team/<team>/… segment of a working ONES URL.","Check your ONES deployment's API version against the filters/peek docs; if the envelope changed, update the CLI.","Confirm the plain `opencli ones tasks` (empty must) works to isolate whether the issue is your filter query or the response schema."],"exampleFix":"// before: diagnosing with a wrong team uuid\nONES_TEAM_UUID='00000000' opencli ones tasks\n// after: use the team from your ONES URL\nONES_TEAM_UUID='AbCd1234' opencli ones tasks","handlingStrategy":"type-guard","validationCode":"// guard before consuming peek output yourself\nif (!parsed || typeof parsed !== 'object' || !Array.isArray(parsed.groups)) {\n  console.error('filters/peek returned no groups — verify ONES_TEAM_UUID and API version; inspect with -f json.');\n}","typeGuard":"function isPeekPayload(p) {\n  return p !== null && typeof p === 'object' && Array.isArray(p.groups) &&\n    p.groups.every(g => g === null || typeof g !== 'object' || Array.isArray(g.entries) || g.entries === undefined);\n}","tryCatchPattern":"try {\n  const rows = await opencli.ones.tasks();\n} catch (e) {\n  if (e.code === 'FETCH_ERROR' && /missing groups/.test(e.message)) {\n    console.error('Dump raw payload with -f json; check team UUID and ONES API version.');\n  } else throw e;\n}","preventionTips":["Keep ONES_TEAM_UUID current after workspace migrations.","Run `opencli ones tasks -f json` once to confirm the peek envelope for your server version.","Pin/verify your ONES deployment version against the CLI's expected API."],"tags":["ones","api","response-shape","schema-mismatch"],"backgroundTag":"unexpected-api-response-shape","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}