{"record":{"id":"a3f8a4c70c9aed91","repo":"jackwener/OpenCLI","slug":"chatgpt-project-file-add-requires-at-least-one-fil","errorCode":null,"errorMessage":"chatgpt project-file-add requires at least one file path","messagePattern":"chatgpt project-file-add requires at least one file path","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/chatgpt/project-file-add.js","lineNumber":38,"sourceCode":"export const projectFileAddCommand = cli({\n    site: 'chatgpt',\n    name: 'project-file-add',\n    access: 'write',\n    description: 'Upload files to a ChatGPT project as project knowledge (not just conversation attachments)',\n    domain: CHATGPT_DOMAIN,\n    strategy: Strategy.COOKIE,\n    browser: true,\n    siteSession: 'persistent',\n    navigateBefore: false,\n    args: [\n        { name: 'file', positional: true, required: true, help: 'Local file path(s) to upload; comma-separated paths are supported' },\n        { 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(","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/chatgpt/project-file-add.js#L20-L56","documentation":"ArgumentError thrown by `chatgpt project-file-add` when `parseFilePaths(kwargs.file)` yields an empty list — i.e. no `--file` path was supplied (or all supplied paths were empty). The command needs at least one file to upload to project knowledge.","triggerScenarios":"Invoking `opencli chatgpt project-file-add --id <id>` without `--file`, or with a value that parses to zero paths.","commonSituations":"Forgetting the --file flag; quoting mistakes so the argument is empty; scripts passing an empty variable; passing a directory instead of file paths that the parser drops.","solutions":["Pass at least one file path: `opencli chatgpt project-file-add report.pdf --id 12345678`.","Check shell quoting / variable expansion so --file receives a non-empty value.","Repeat --file for each path if multiple files are needed."],"exampleFix":"// before\nopencli chatgpt project-file-add --id 12345678\n// after\nopencli chatgpt project-file-add report.pdf --id 12345678","handlingStrategy":"validation","validationCode":"const files = process.argv.filter(a => !a.startsWith('--'));\nif (!files.length) {\n  console.error('Usage: opencli chatgpt project-file-add <file...> --id <projectId>');\n  process.exit(2);\n}","typeGuard":"function hasFilePaths(v) { return Array.isArray(v) && v.length > 0 && v.every(p => typeof p === 'string' && p.trim() !== ''); }","tryCatchPattern":"try {\n  await run(['chatgpt', 'project-file-add', ...files, '--id', id]);\n} catch (err) {\n  if (String(err.message).includes('requires at least one file path')) {\n    console.error('Provide at least one file, e.g. report.pdf');\n  }\n}","preventionTips":["Always pass at least one --file value; validate args in wrapper scripts.","Check shell quoting so --file never expands to an empty string.","Fail fast in CI if the file list variable is empty."],"tags":["argument-validation","cli","chatgpt","missing-argument"],"backgroundTag":"missing-required-argument","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}