alibaba/spring-ai-alibaba · error · RuntimeException

file does not exist, path:

Error message

file does not exist, path: 

What it means

KnowledgeBaseIndexPipeline.parse builds a File from the resolved path (downloaded OSS file or storage-path FILE document) and throws RuntimeException "file does not exist, path: " + path when the file cannot be found on local disk before attempting format-specific parsing.

Source

Thrown at spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-core/src/main/java/com/alibaba/cloud/ai/studio/core/rag/indices/KnowledgeBaseIndexPipeline.java:95

		List<Document> documents;
		String format = document.getFormat();

		String path;
		if (document.getType() == DocumentType.OSS
				|| UploadType.OSS.getValue().equalsIgnoreCase(properties.getUploadMethod())) {
			path = FileUtils.getTempFilePath(document.getDocId());
			ossManager.downloadFile(document.getPath(), path);
		}
		else if (document.getType() == DocumentType.FILE) {
			path = properties.getStoragePath() + File.separator + document.getPath();
		}
		else {
			throw new RuntimeException("unsupported document type: " + document.getType());
		}

		File file = new File(path);
		if (!file.exists()) {
			throw new RuntimeException("file does not exist, path: " + path);
		}

		format = StringUtils.lowerCase(format);
		switch (format) {
			case "pdf": {
				DocumentReader reader = new PagePdfDocumentReader(new FileSystemResource(file));
				documents = reader.get();
				break;
			}
			case "doc", "docx", "ppt", "pptx": {
				DocumentReader reader = new TikaDocumentReader(new FileSystemResource(file));
				documents = reader.get();
				break;
			}
			case "md", "markdown": {
				DocumentReader reader = new MarkdownDocumentReader(new FileSystemResource(file),
						MarkdownDocumentReaderConfig.defaultConfig());
				documents = reader.get();

View on GitHub (pinned to f82da0b50f)

Solutions

  1. Verify properties.getStoragePath() points to a persistent, existing directory containing the uploaded files.
  2. Re-upload the document (or re-download from OSS) so the local file exists, then retry indexing.
  3. Check document.getPath() in the DB for stale paths and correct them.
  4. Mount persistent storage (PV/NFS) so uploaded files survive restarts and are visible to all nodes.

Example fix

// before
spring:
  storage:
    path: /tmp/kb-storage
// after
spring:
  storage:
    path: /data/kb-storage  # persistent volume
Defensive patterns

Strategy: validation

Validate before calling

// Java
File file = new File(properties.getStoragePath(), document.getPath());
if (!file.exists()) {
    throw new IllegalStateException("Local file missing for document " + document.getId() + ": " + file.getPath());
}

Try / catch

try {
    docs = pipeline.parse(document, format);
} catch (RuntimeException e) {
    if (e.getMessage() != null && e.getMessage().startsWith("file does not exist")) {
        // trigger re-download/re-upload before retrying indexing
    }
}

Prevention

When it happens

Trigger: parse() is invoked for a document whose local file is absent — the OSS download was skipped/failed, the configured storage-path directory was wiped (container restart with ephemeral storage), or document.getPath() points to a stale/moved file.

Common situations: Kubernetes pods with non-persistent volumes losing previously uploaded files; documents uploaded to an old node in a multi-node deployment; wrong spring.storage.path configuration; file deleted during cleanup jobs while DB row remains.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


AI-assisted analysis of alibaba/spring-ai-alibaba@f82da0b50f (2026-09-09). Data as JSON: /api/errors/1023ff8fdbd0b356. Report an issue: GitHub.