toeverything/AFFiNE · error · napi::Error
InvalidArg
InvalidArg
Error message
unsupported import source kind: {kind} What it means
Sentinel error in the napi `create_import_session` entry point: the caller-supplied `options.source.kind` string did not match any of the supported import source kinds handled in the match (e.g. 'filePath'), so no import session can be constructed. The faulting input is the unrecognized `kind` string in the import source descriptor.
Source
Thrown at packages/frontend/native/src/import/session.rs:64
let status = match error {
affine_importer::ImportError::Cancelled => Status::Cancelled,
affine_importer::ImportError::UnsupportedFormat(_) | affine_importer::ImportError::InvalidSource(_) => {
Status::InvalidArg
}
affine_importer::ImportError::Zip(_)
| affine_importer::ImportError::Io(_)
| affine_importer::ImportError::Document(_) => Status::GenericFailure,
};
Error::new(status, error.to_string())
}
#[napi]
pub fn create_import_session(options: CreateImportSessionOptions) -> Result<String> {
let source = match options.source.kind.as_str() {
"filePath" => ImportSource::FilePath(PathBuf::from(options.source.path)),
"directoryPath" => ImportSource::DirectoryPath(PathBuf::from(options.source.path)),
kind => {
return Err(Error::new(
Status::InvalidArg,
format!("unsupported import source kind: {kind}"),
));
}
};
let mut batch_limits = ImportBatchLimits::default();
if let Some(limits) = options.batch_limits {
if let Some(max_docs) = limits.max_docs {
batch_limits.max_docs = max_docs as usize;
}
if let Some(max_blobs) = limits.max_blobs {
batch_limits.max_blobs = max_blobs as usize;
}
if let Some(max_blob_bytes) = limits.max_blob_bytes {
if !(0..=100 * 1024 * 1024).contains(&max_blob_bytes) {
return Err(Error::new(Status::InvalidArg, "maxBlobBytes not valid"));
}
batch_limits.max_blob_bytes = max_blob_bytes as u64;View on GitHub (pinned to b4c8548c09)
Solutions
- Use a supported import source kind.
- Add a handler for the new import kind.
Defensive patterns
Strategy: validation
When it happens
Trigger: Raised in create_import_session when options.source.kind is neither filePath nor directoryPath.
Common situations: The import request used an unknown source kind. Use filePath or directoryPath when starting an import session.
AI-assisted analysis of toeverything/AFFiNE@b4c8548c09 (2026-08-18).
Data as JSON: /api/errors/6b54444d60543fa5.
Report an issue: GitHub.