jackwener/OpenCLI · error · CommandExecutionError

Failed to upload file to ChatGPT project knowledge

Error message

Failed to upload file to ChatGPT project knowledge

What it means

CommandExecutionError thrown when the upload result is neither an input error nor `ok` — the upload helper finished but reported a non-input failure (via `upload.reason`) or returned nothing usable. It indicates the ChatGPT project knowledge upload did not complete.

Source

Thrown at clis/chatgpt/project-file-add.js:63

        let upload;
        try {
            upload = await uploadChatGPTProjectFiles(page, projectId, filePaths);
        } catch (err) {
            throw new CommandExecutionError(
                `Failed to upload file to ChatGPT project knowledge: ${err instanceof Error ? err.message : String(err)}`,
            );
        }

        if (upload?.inputError) {
            throw new ArgumentError(
                upload.reason || 'Invalid project file path',
                'Provide an existing local file path that ChatGPT project knowledge can upload.',
            );
        }

        if (!upload?.ok) {
            throw new CommandExecutionError(
                upload?.reason || 'Failed to upload file to ChatGPT project knowledge',
                `Open ${CHATGPT_URL}/g/g-p-${projectId} and verify the project accepts file uploads. If your browser needs a proxy, configure it outside this command.`,
            );
        }

        return upload.files.map(file => ({
            Status: '📄 uploaded to project knowledge',
            File: file,
        }));
    },
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Open https://chatgpt.com/g/g-p-<projectId> manually and confirm the project accepts file uploads.
  2. Check upload.reason in the error detail for the specific failure.
  3. Verify file meets ChatGPT size/type limits and re-upload.
  4. Configure browser proxy outside this command if networking requires one; ensure a fresh logged-in session.
Defensive patterns

Strategy: try-catch

Validate before calling

// Confirm project page is usable before upload
const ok = await page.goto(`https://chatgpt.com/g/g-p-${projectId}`).then(r => r.ok()).catch(() => false);
if (!ok) throw new Error(`Project page /g/g-p-${projectId} not reachable; check login/proxy`);

Type guard

function uploadSucceeded(u) { return u !== null && typeof u === 'object' && u.ok === true && Array.isArray(u.files); }

Try / catch

try {
  await run(['chatgpt', 'project-file-add', ...filePaths, '--id', id]);
} catch (err) {
  if (String(err.message).includes('Failed to upload file to ChatGPT project knowledge')) {
    console.error(`Open https://chatgpt.com/g/g-p-${id} and verify the project accepts uploads; configure proxy outside the command if needed.`);
  }
}

Prevention

When it happens

Trigger: `uploadChatGPTProjectFiles` resolves with `ok: false` (or an undefined/empty upload) after the input checks pass.

Common situations: ChatGPT rejected the file (size/format limits); project page failed to accept uploads; browser needs a proxy configured outside the command; session expired mid-flow; DOM changes broke the post-upload confirmation detection.

Related errors


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