jackwener/OpenCLI · error · ArgumentError

Invalid project file path

Error message

Invalid project file path

What it means

ArgumentError thrown when `uploadChatGPTProjectFiles` reports `upload.inputError` but no `upload.reason` — meaning ChatGPT/automation rejected the input (typically an invalid or nonexistent file path or an unusable project id). The default message is 'Invalid project file path'.

Solutions

  1. Verify each file path exists locally (`ls <path>` / `Test-Path`) before running the command.
  2. Check the project ID: it must be a numeric ID or a /g/g-p-<id> URL.
  3. Re-run with `upload.reason`-reported detail if a reason was provided.
  4. Use absolute paths to avoid working-directory confusion.

Example fix

// before
opencli chatgpt project-file-add repport.pdf --id abc
// after (path exists, id is valid)
opencli chatgpt project-file-add report.pdf --id 12345678
Defensive patterns

Strategy: validation

Validate before calling

const missing = filePaths.filter(p => !fs.existsSync(p) || !fs.statSync(p).isFile());
if (missing.length) throw new Error(`Not a valid file path: ${missing.join(', ')}`);
if (!/^(\d+|\/g\/g-p-\d+)$/.test(idArg)) throw new Error(`Invalid project id: ${idArg}`);

Type guard

function isValidFilePath(p) { return typeof p === 'string' && p.trim() !== '' && fs.existsSync(p) && fs.statSync(p).isFile(); }

Try / catch

try {
  await run(['chatgpt', 'project-file-add', ...filePaths, '--id', id]);
} catch (err) {
  if (String(err.message).includes('Invalid project file path')) {
    console.error('Check each path exists and the project id matches /g/g-p-<id>');
  }
}

Prevention

When it happens

Trigger: `upload.inputError` is truthy after the upload call; the upload helper flagged a user-input problem such as a file that does not exist locally or a malformed project id.

Common situations: Typo'd or deleted local file path; passing a directory or URL where a file path is expected; wrong/invalid project ID (not matching /g/g-p-<id>); case-sensitivity issues on the path.

Related errors


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

Appendix: source

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

            throw new ArgumentError(
                'chatgpt project-file-add requires at least one file path',
                'Example: opencli chatgpt project-file-add report.pdf --id 12345678',
            );
        }

        const projectId = parseChatGPTProjectId(kwargs.id);

        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)