Skip to content

fix(chatgpt): drop unused second arg from getChatGPTImageAssets evaluate#1556

Open
ele-yufo wants to merge 1 commit into
jackwener:mainfrom
ele-yufo:fix/chatgpt-image-evaluate-args
Open

fix(chatgpt): drop unused second arg from getChatGPTImageAssets evaluate#1556
ele-yufo wants to merge 1 commit into
jackwener:mainfrom
ele-yufo:fix/chatgpt-image-evaluate-args

Conversation

@ele-yufo
Copy link
Copy Markdown

Summary

getChatGPTImageAssets passes the URL list both ways:

const urlsJson = JSON.stringify(urls);
return await page.evaluate(`
    (async (targetUrls) => { ... })(${urlsJson})   // ← inlined here
`, urls);                                          // ← also as a CDP arg

Browser bridge 1.7.x rejects the second form for string scripts:

page.evaluate string input does not accept args; use page.evaluate(fn, ...args) instead

So any opencli chatgpt image <prompt> that actually downloads the asset (i.e. without --sd true) fails with code: UNKNOWN.

Fix

Drop the trailing , urls argument. The URLs are already inlined via the ${urlsJson} template substitution, so no semantic change — only the redundant + now-invalid CDP arg is removed.

Root cause

The redundant arg was harmless in older bridge versions; the strict-mode guard was added in browser/utils.ts:

if (args.length > 0) {
    throw new Error('page.evaluate string input does not accept args; ...');
}

Validation

  • npx tsc --noEmit clean
  • npx vitest run --project adapter clis/chatgpt/ — 25/25 pass (3 files)
  • Live: opencli chatgpt image "a fluffy orange cat" --op /tmp/x succeeds end-to-end after the fix (fails before with the error above)

Scope

Single-line change in clis/chatgpt/utils.js. No new tests — the existing image.test.js mocks getChatGPTImageAssets, so this codepath is only exercised against a live browser. Happy to add an integration-style assertion if the reviewer prefers.

The IIFE inside the evaluate string already receives the URL list via
the embedded `${urlsJson}` template substitution, so the trailing
`, urls` argument to `page.evaluate` is redundant.

It also fails hard against the post-1.7.x browser bridge guard:

    page.evaluate string input does not accept args;
    use page.evaluate(fn, ...args) instead

This breaks every `opencli chatgpt image` invocation that downloads
the generated asset (i.e. anything without `--sd true`).

Fix: drop the trailing argument. The function already has the URLs
inlined in the evaluated script, so no behaviour change beyond
unblocking the download path.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant