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.

Solutions

  1. In desktop mode, pass the native file path (from JCEF file dialog) as input.filePath instead of a File object.
  2. Ensure the JCEF file dialog handler returns and forwards the absolute file path.
  3. 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

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


AI-assisted analysis of OtterMind/Chat2DB@5ee1e990e7 (2026-08-14). Data as JSON: /api/errors/3b68f50aeff024fc. Report an issue: GitHub.

Appendix: 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)