jackwener/OpenCLI · error · Error

workspace/create returned no workspace_id: ${JSON.stringify(

Error message

workspace/create returned no workspace_id: ${JSON.stringify(resp).substring(0, 200)}

What it means

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.

Source

Thrown at clis/jimeng/new.js:30

        { navigate: 'https://jimeng.jianying.com/ai-tool/generate?type=image&workspace=0' },
        { evaluate: `(async () => {
  const resp = await fetch('/mweb/v1/workspace/create?aid=513695', {
    method: 'POST',
    credentials: 'include',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({})
  }).then(r => r.json());

  if (resp.ret === '1014' || resp.ret === 1014) {
    throw new Error('Not logged in — open jimeng.jianying.com in Chrome and sign in first');
  }
  if (resp.ret !== '0' && resp.ret !== 0) {
    throw new Error('workspace/create failed: ret=' + resp.ret + ' errmsg=' + (resp.errmsg || ''));
  }

  const wsId = resp.data?.workspace_id;
  if (!wsId) {
    throw new Error('workspace/create returned no workspace_id: ' + JSON.stringify(resp).substring(0, 200));
  }

  return [{
    workspace_id: String(wsId),
    workspace_url: 'https://jimeng.jianying.com/ai-tool/generate?type=image&workspace=' + wsId,
  }];
})()
` },
        { map: {
                workspace_id: '${{ item.workspace_id }}',
                workspace_url: '${{ item.workspace_url }}',
            } },
    ],
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Inspect the 200-char JSON dump in the message to find where the id actually lives.
  2. Log in to jimeng.jianying.com manually and create a workspace in the UI to confirm the feature still works.
  3. Update the CLI's evaluate script to read the id from the new location (e.g. resp.data.workspace.id).
  4. Retry later if the API is mid-rollout and intermittently returns the new shape.
  5. Check for CLI updates that track the current Jimeng API.

Example fix

// Support renamed/nested id:
// before
const wsId = resp.data?.workspace_id;
// after
const wsId = resp.data?.workspace_id ?? resp.data?.workspace?.id;
Defensive patterns

Strategy: type-guard

Validate before calling

// Nothing to validate pre-call; instead handle the schema mismatch:
const dump = e.message.match(/no workspace_id: (.*)$/)?.[1];
console.log(JSON.parse(dump ?? '{}'));

Type guard

function hasWorkspaceId(resp) {
  return Boolean(resp && resp.data && typeof resp.data.workspace_id !== 'undefined' && resp.data.workspace_id !== null);
}

Try / catch

try {
  const ws = await run(['jimeng', 'new']);
} catch (e) {
  if (String(e.message).includes('returned no workspace_id')) {
    const body = JSON.parse(e.message.split('no workspace_id: ')[1] || '{}');
    console.error('Unexpected success envelope:', body);
  } else throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


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