{"record":{"id":"3d3de423d1352830","repo":"jackwener/OpenCLI","slug":"workspace-create-failed-ret-resp-ret-errmsg","errorCode":null,"errorMessage":"workspace/create failed: ret=${resp.ret} errmsg=${resp.errmsg || ''}","messagePattern":"workspace/create failed: ret=(.+?) errmsg=(.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"clis/jimeng/new.js","lineNumber":25,"sourceCode":"    domain: 'jimeng.jianying.com',\n    strategy: Strategy.COOKIE,\n    browser: true,\n    columns: ['workspace_id', 'workspace_url'],\n    pipeline: [\n        { navigate: 'https://jimeng.jianying.com/ai-tool/generate?type=image&workspace=0' },\n        { evaluate: `(async () => {\n  const resp = await fetch('/mweb/v1/workspace/create?aid=513695', {\n    method: 'POST',\n    credentials: 'include',\n    headers: { 'Content-Type': 'application/json' },\n    body: JSON.stringify({})\n  }).then(r => r.json());\n\n  if (resp.ret === '1014' || resp.ret === 1014) {\n    throw new Error('Not logged in — open jimeng.jianying.com in Chrome and sign in first');\n  }\n  if (resp.ret !== '0' && resp.ret !== 0) {\n    throw new Error('workspace/create failed: ret=' + resp.ret + ' errmsg=' + (resp.errmsg || ''));\n  }\n\n  const wsId = resp.data?.workspace_id;\n  if (!wsId) {\n    throw new Error('workspace/create returned no workspace_id: ' + JSON.stringify(resp).substring(0, 200));\n  }\n\n  return [{\n    workspace_id: String(wsId),\n    workspace_url: 'https://jimeng.jianying.com/ai-tool/generate?type=image&workspace=' + wsId,\n  }];\n})()\n` },\n        { map: {\n                workspace_id: '${{ item.workspace_id }}',\n                workspace_url: '${{ item.workspace_url }}',\n            } },\n    ],","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/jimeng/new.js#L7-L43","documentation":"This error is thrown by the jimeng `new` CLI command when the POST to /mweb/v1/workspace/create returns an API-level failure: the `ret` code is anything other than 0 ('0' or 0). The Jimeng web API wraps results in a {ret, errmsg, data} envelope, so a non-zero `ret` means the server rejected the workspace-creation request. The error surfaces the raw `ret` code and `errmsg` verbatim so you can diagnose the exact server-side rejection.","triggerScenarios":"Running `jimeng new` where the browser-context fetch to /mweb/v1/workspace/create?aid=513695 responds with {ret: <non-zero>}. Note the specific ret 1014 is handled earlier as a login error, so this error means some other code: rate limiting, CSRF/timestamp mismatch, region restrictions, or API contract changes.","commonSituations":"Jimeng changed its workspace/create API (new required fields or error codes); requests throttled after repeated runs; a stale or partially-valid session cookie passes the 1014 check but fails authorization; network proxy or region block returning an error envelope.","solutions":["Read the `ret` and `errmsg` in the message and look up that specific code in Jimeng's API; fix the underlying cause it describes.","Re-check that you are properly signed in to jimeng.jianying.com in Chrome (ret 1014 is the explicit 'not logged in' code; other codes may still be session-related) and retry.","Wait and retry if the message suggests throttling/frequency limits.","Update the CLI: if Jimeng changed the create payload, the embedded evaluate script may need new headers/body fields.","Inspect the raw response manually in Chrome DevTools from the site to compare a working request with the CLI's request."],"exampleFix":"// If Jimeng started requiring a payload field:\n// before\nbody: JSON.stringify({})\n// after\nbody: JSON.stringify({ app_id: 513695, scene: 1 })","handlingStrategy":"try-catch","validationCode":"// Check session before running:\n// 1. Confirm signed in: open jimeng.jianying.com in Chrome.\n// 2. Confirm cookie presence before invoking the CLI.","typeGuard":"function isOkEnvelope(resp) {\n  return resp && (resp.ret === '0' || resp.ret === 0) && resp.data?.workspace_id;\n}","tryCatchPattern":"try {\n  await run(['jimeng', 'new']);\n} catch (e) {\n  if (String(e.message).startsWith('workspace/create failed:')) {\n    const m = e.message.match(/ret=(\\S+) errmsg=(.*)/);\n    console.error(`Jimeng rejected create (ret=${m?.[1]}): ${m?.[2]}`);\n    // handle per ret code: throttle -> retry with backoff, contract change -> update CLI\n  } else throw e;\n}","preventionTips":["Sign in to jimeng.jianying.com in Chrome before running cookie-based commands.","Avoid rapid repeated invocations that trip frequency limits.","Keep the CLI updated against Jimeng API changes.","Log full envelopes when debugging instead of guessing codes."],"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"}