OtterMind/Chat2DB · error · Error
Missing local file path
Error message
Missing local file path
What it means
parseAttachment throws 'Missing local file path' when running in desktop mode (isDesktop === true) but input.filePath is not provided. In the desktop (JCEF) runtime, file parsing uses a local file path via parseLocalAttachment (POST /api/v3/ai/chat/attachment/parse/local) rather than an uploaded File object. The file path is the only way for the desktop backend to locate and read the file.
Source
Thrown at chat2db-community-client/src/service/aiAttachment.ts:31
const parseUploadedAttachment = createRequest<{ file: File }, IChatAttachment>(
'/api/v3/ai/chat/attachment/parse/upload',
{
method: 'post',
contentType: 'formData',
},
);
const parseLocalAttachment = createRequest<{ filePath: string; fileName?: string }, IChatAttachment>(
'/api/v3/ai/chat/attachment/parse/local',
{
method: 'post',
},
);
async function parseAttachment(input: { file?: File; filePath?: string; fileName?: string }) {
if (isDesktop) {
if (!input.filePath) {
throw new Error('Missing local file path');
}
return parseLocalAttachment({
filePath: input.filePath,
fileName: input.fileName,
});
}
if (!input.file) {
throw new Error('Missing file');
}
return parseUploadedAttachment({
file: input.file,
});
}
export default {
parseAttachment,View on GitHub (pinned to 5ee1e990e7)
Solutions
- In desktop mode, pass the native file path (from JCEF file dialog) as input.filePath instead of a File object.
- Ensure the JCEF file dialog handler returns and forwards the absolute file path.
- Add a guard before calling parseAttachment to verify isDesktop implies filePath is present.
Example fix
// before
await parseAttachment({ file });
// after
await parseAttachment({
filePath: isDesktop ? file.path : undefined,
file: isDesktop ? undefined : file,
fileName: file.name,
}); Defensive patterns
Strategy: validation
Validate before calling
function isDesktopAttachmentInput(input: { filePath?: string; file?: File }): input is { filePath: string } {
return isDesktop && typeof input.filePath === 'string' && input.filePath.length > 0;
}
if (isDesktop && !input.filePath) {
throw new Error('Desktop mode requires a file path from the JCEF file dialog');
} Type guard
function hasFilePath(input: unknown): input is { filePath: string } {
return !!input && typeof input === 'object' && typeof (input as any).filePath === 'string';
} Prevention
- In desktop mode, always obtain and pass the native file path from the JCEF dialog.
- Ensure the JCEF file picker returns the absolute path, not just a File object.
- Validate filePath presence before calling parseAttachment.
When it happens
Trigger: Calling parseAttachment({ file: someFile }) or parseAttachment({}) while isDesktop is true. This occurs when desktop code passes a File object (web-style) instead of a file path, or when the JCEF file dialog fails to return a path.
Common situations: Desktop build where the JCEF file picker returns a File but not its native path. Migrating web attachment code to desktop without converting File to filePath. A bug in the JCEF bridge where the native path is not exposed.
Related errors
- Failed to update local file
- Missing file
- Failed to load frontend files
- The baseURL is not valid!
- Fetch failed with status ${response.status}
AI-assisted analysis of OtterMind/Chat2DB@5ee1e990e7 (2026-08-14).
Data as JSON: /api/errors/3b68f50aeff024fc.
Report an issue: GitHub.