{"record":{"id":"9b88c80b2d01c2ee","repo":"jackwener/OpenCLI","slug":"workspace-create-returned-no-workspace-id-json","errorCode":null,"errorMessage":"workspace/create returned no workspace_id: ${JSON.stringify(resp).substring(0, 200)}","messagePattern":"workspace/create returned no workspace_id: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"clis/jimeng/new.js","lineNumber":30,"sourceCode":"        { 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    ],\n});\n","sourceCodeStart":12,"sourceCodeEnd":45,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/jimeng/new.js#L12-L45","documentation":"Thrown after the workspace/create call reports success (ret === 0) but the response body contains no `data.workspace_id`. The CLI considers a success envelope without the expected id a protocol violation: it cannot build the workspace URL without the id. It dumps the first 200 chars of the JSON response for diagnosis.","triggerScenarios":"The API returns {ret: 0, data: null}, {ret: 0, data: {}}, or nests the id under a different key (e.g. data.workspace.id) — i.e. a silent-success response with a schema the CLI doesn't expect.","commonSituations":"Jimeng A/B-testing a new response shape or renaming the field; regional API variants returning different payloads; a 'soft success' where creation was queued asynchronously and no id is present yet.","solutions":["Inspect the 200-char JSON dump in the message to find where the id actually lives.","Log in to jimeng.jianying.com manually and create a workspace in the UI to confirm the feature still works.","Update the CLI's evaluate script to read the id from the new location (e.g. resp.data.workspace.id).","Retry later if the API is mid-rollout and intermittently returns the new shape.","Check for CLI updates that track the current Jimeng API."],"exampleFix":"// Support renamed/nested id:\n// before\nconst wsId = resp.data?.workspace_id;\n// after\nconst wsId = resp.data?.workspace_id ?? resp.data?.workspace?.id;","handlingStrategy":"type-guard","validationCode":"// Nothing to validate pre-call; instead handle the schema mismatch:\nconst dump = e.message.match(/no workspace_id: (.*)$/)?.[1];\nconsole.log(JSON.parse(dump ?? '{}'));","typeGuard":"function hasWorkspaceId(resp) {\n  return Boolean(resp && resp.data && typeof resp.data.workspace_id !== 'undefined' && resp.data.workspace_id !== null);\n}","tryCatchPattern":"try {\n  const ws = await run(['jimeng', 'new']);\n} catch (e) {\n  if (String(e.message).includes('returned no workspace_id')) {\n    const body = JSON.parse(e.message.split('no workspace_id: ')[1] || '{}');\n    console.error('Unexpected success envelope:', body);\n  } else throw e;\n}","preventionTips":["Inspect the response dump in the message to spot schema changes early.","Pin/monitor CLI versions that track Jimeng API changes.","Retry manually if the API is mid-rollout."],"tags":["api","schema","cli","response-shape"],"backgroundTag":"missing-response-field","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}