{"record":{"id":"3c3ac1989d660624","repo":"jackwener/OpenCLI","slug":"workspace-list-failed-ret-data-ret-errmsg-da","errorCode":null,"errorMessage":"workspace/list failed: ret=${data.ret} errmsg=${data.errmsg || ''}","messagePattern":"workspace/list failed: ret=(.+?) errmsg=(.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"clis/jimeng/workspaces.js","lineNumber":25,"sourceCode":"    domain: 'jimeng.jianying.com',\n    strategy: Strategy.COOKIE,\n    browser: true,\n    columns: ['workspace_id', 'name', 'is_pinned', 'updated_at'],\n    pipeline: [\n        { navigate: 'https://jimeng.jianying.com/ai-tool/generate?type=image&workspace=0' },\n        { evaluate: `(async () => {\n  const res = await fetch('/mweb/v1/workspace/list?aid=513695&web_version=7.5.0&da_version=3.3.12', {\n    method: 'POST',\n    credentials: 'include',\n    headers: { 'Content-Type': 'application/json' },\n    body: JSON.stringify({})\n  });\n  const data = await res.json();\n  if (data.ret === '1014' || data.ret === 1014) {\n    throw new Error('Not logged in — open jimeng.jianying.com in Chrome and sign in first');\n  }\n  if (data.ret !== '0' && data.ret !== 0) {\n    throw new Error('workspace/list failed: ret=' + data.ret + ' errmsg=' + (data.errmsg || ''));\n  }\n  return (data.data?.workspaces || []).map(ws => ({\n    workspace_id: String(ws.workspace_id),\n    name: ws.name || '',\n    is_pinned: ws.is_pinned ? 'yes' : 'no',\n    updated_at: ws.update_time ? new Date(ws.update_time).toLocaleString('zh-CN') : '',\n  }));\n})()\n` },\n        { map: {\n                workspace_id: '${{ item.workspace_id }}',\n                name: '${{ item.name }}',\n                is_pinned: '${{ item.is_pinned }}',\n                updated_at: '${{ item.updated_at }}',\n            } },\n    ],\n});\n","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/jimeng/workspaces.js#L7-L43","documentation":"Thrown by the `jimeng workspaces` command when the workspace/list endpoint returns a non-zero `ret` other than the specific 1014 'not logged in' code. It echoes the raw `ret` and `errmsg` from Jimeng's {ret, errmsg, data} envelope, indicating the server rejected the list request for a reason other than plain authentication.","triggerScenarios":"fetch to the workspace/list endpoint (credentials: 'include') resolves with {ret: <non-zero, not 1014>}: e.g. rate limiting, permission/version errors, or API contract changes.","commonSituations":"Polling the list too frequently triggers frequency-limit ret codes; Jimeng changes the endpoint or adds required params; a semi-valid session passes some endpoints but fails others; region or service incident.","solutions":["Read the `ret`/`errmsg` in the message and address the specific server-side cause it names.","Slow down / retry after a pause if the code indicates frequency limits.","Re-sign in to jimeng.jianying.com in Chrome — some session issues surface as codes other than 1014.","Check jimeng.jianying.com availability in the browser; if the site itself errors, wait for the incident to resolve.","Update the CLI if the endpoint contract changed."],"exampleFix":"// Add retry for transient/frequency codes:\n// before\nif (data.ret !== '0' && data.ret !== 0) { throw new Error('workspace/list failed: ret=' + data.ret + ...); }\n// after\nif (data.ret === '1080' /* frequency limit */) { await sleep(2000); return listWorkspaces(); }\nif (data.ret !== '0' && data.ret !== 0) { throw new Error('workspace/list failed: ret=' + data.ret + ...); }","handlingStrategy":"retry","validationCode":"// Throttle your own polling:\nif (Date.now() - lastListRun < 5000) throw new Error('list called too soon');","typeGuard":"function isOkEnvelope(data) {\n  return data && (data.ret === '0' || data.ret === 0) && Array.isArray(data.data?.workspaces);\n}","tryCatchPattern":"try {\n  await run(['jimeng', 'workspaces']);\n} catch (e) {\n  const m = String(e.message).match(/workspace\\/list failed: ret=(\\S+)/);\n  if (m && isFrequencyCode(m[1])) {\n    await new Promise(r => setTimeout(r, 5000));\n    return run(['jimeng', 'workspaces']); // bounded retry\n  }\n  throw e;\n}","preventionTips":["Add backoff between polling runs to avoid frequency-limit ret codes.","Confirm site health in a browser when many commands fail at once.","Keep CLI updated for endpoint contract changes.","Re-sign in if session-related codes persist."],"tags":["api","http","cookie-auth","cli"],"backgroundTag":"api-error-envelope","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}