toeverything/AFFiNE · error

Native import requires a local file source

Error message

Native import requires a local file source

What it means

createImportSessionFromSource resolves the import source to a local file/directory path and throws when the source is not local (e.g. remote or cloud content), since native import only operates on filesystem paths.

Source

Thrown at packages/frontend/apps/electron/src/preload/electron-api.ts:328

  if (source.kind === 'file') {
    const path = filePathFromFile(source.file);
    return path ? { kind: 'filePath', path } : null;
  }
  const path = directoryPathFromFiles(source.files);
  return path ? { kind: 'directoryPath', path } : null;
}

export const apis = {
  ...mainAPIs.apis,
  ...helperAPIs.apis,
  import: {
    ...mainAPIs.apis.import,
    createImportSessionFromSource(
      options: CreateImportSessionFromSourceOptions
    ) {
      const source = resolveNativeImportSource(options.source);
      if (!source) {
        throw new Error('Native import requires a local file source');
      }
      return mainAPIs.apis.import.createImportSession({
        format: options.format,
        source,
        batchLimits: options.batchLimits,
      });
    },
  },
};

export const events = {
  ...mainAPIs.events,
  ...helperAPIs.events,
};

View on GitHub (pinned to b4c8548c09)

Solutions

  1. Import from a local file path when using the native import API.
  2. Download the remote content to a local file first, then import it.
  3. Check the import call site to ensure a file source is passed instead of a URL or blob.
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at packages/frontend/apps/electron/src/preload/electron-api.ts:328 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of toeverything/AFFiNE@b4c8548c09 (2026-08-18). Data as JSON: /api/errors/09fb56cdbd93eac1. Report an issue: GitHub.