{"record":{"id":"0e142ac3911741f9","repo":"jackwener/OpenCLI","slug":"failed-to-upload-file-to-chatgpt-project-knowledge","errorCode":null,"errorMessage":"Failed to upload file to ChatGPT project knowledge: ${err instanceof Error ? err.message : String(err)}","messagePattern":"Failed to upload file to ChatGPT project knowledge: (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/chatgpt/project-file-add.js","lineNumber":50,"sourceCode":"        { name: 'id', required: true, help: 'Project ID or /g/g-p-<id> URL' },\n    ],\n    columns: ['Status', 'File'],\n    func: async (page, kwargs) => {\n        const filePaths = parseFilePaths(kwargs.file);\n        if (!filePaths.length) {\n            throw new ArgumentError(\n                'chatgpt project-file-add requires at least one file path',\n                'Example: opencli chatgpt project-file-add report.pdf --id 12345678',\n            );\n        }\n\n        const projectId = parseChatGPTProjectId(kwargs.id);\n\n        let upload;\n        try {\n            upload = await uploadChatGPTProjectFiles(page, projectId, filePaths);\n        } catch (err) {\n            throw new CommandExecutionError(\n                `Failed to upload file to ChatGPT project knowledge: ${err instanceof Error ? err.message : String(err)}`,\n            );\n        }\n\n        if (upload?.inputError) {\n            throw new ArgumentError(\n                upload.reason || 'Invalid project file path',\n                'Provide an existing local file path that ChatGPT project knowledge can upload.',\n            );\n        }\n\n        if (!upload?.ok) {\n            throw new CommandExecutionError(\n                upload?.reason || 'Failed to upload file to ChatGPT project knowledge',\n                `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.`,\n            );\n        }\n","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/chatgpt/project-file-add.js#L32-L68","documentation":"CommandExecutionError wrapping any error raised by `uploadChatGPTProjectFiles` — navigation failures, selector timeouts, unexpected DOM, or page errors during upload. The original error message is appended to the message.","triggerScenarios":"The try/catch around `uploadChatGPTProjectFiles(page, projectId, filePaths)` catches any thrown error while uploading local files to a ChatGPT project's knowledge.","commonSituations":"Not logged into ChatGPT so the upload page redirected to login; proxy/network issues reaching ChatGPT; ChatGPT DOM changed so the upload flow's selectors fail; project page rejected the navigation.","solutions":["Read the wrapped message for the root cause and fix that underlying issue first.","Confirm you have a logged-in ChatGPT session before running the command.","Check network/proxy connectivity to chatgpt.com.","Retry; if it persists, update the CLI's upload automation to the current ChatGPT UI."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Pre-checks before upload\nconst files = filePaths.filter(p => fs.existsSync(p));\nif (!files.length) throw new Error('No valid local files to upload');\nif (!/^\\d+$|^\\/g\\/g-p-\\d+/.test(projectIdArg)) throw new Error('Invalid project id');","typeGuard":"function isUploadResult(u) { return u !== null && typeof u === 'object'; }","tryCatchPattern":"try {\n  await run(['chatgpt', 'project-file-add', ...files, '--id', id]);\n} catch (err) {\n  const msg = String(err.message);\n  if (msg.startsWith('Failed to upload file to ChatGPT project knowledge:')) {\n    console.error('Root cause:', msg.split(': ').slice(1).join(': '));\n  }\n}","preventionTips":["Ensure a logged-in ChatGPT session before uploading.","Verify network/proxy reachability of chatgpt.com.","Check that all file paths exist before invoking the command.","Update automation selectors after ChatGPT UI changes."],"tags":["browser-automation","chatgpt","upload","wrapped-error"],"backgroundTag":"automation-upload-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}