OtterMind/Chat2DB · error · BusinessException

ai.attachment.filePathRequired

ai.attachment.filePathRequired

Error message

ai.attachment.filePathRequired

What it means

Thrown by AiAttachmentServiceImpl.parse(AiLocalAttachmentParseRequest) when the parse request is null or its filePath is blank. This is the local-file parse entrypoint (server-side path), distinct from the InputStream-based overload; it refuses to proceed without a concrete filesystem path. The i18n message resolves to 'File path is required'.

Source

Thrown at chat2db-community-server/chat2db-community-domain/chat2db-community-domain-core/src/main/java/ai/chat2db/community/domain/core/impl/ai/AiAttachmentServiceImpl.java:68

        supportedExtensions.addAll(TABULAR_EXTENSIONS);
        SUPPORTED_EXTENSIONS = supportedExtensions;
    }

    public ChatAttachment parse(AiAttachmentParseRequest param) {
        if (param == null || param.getInputStream() == null) {
            throw new BusinessException("ai.attachment.inputStreamRequired");
        }
        String fileName = StringUtils.defaultIfBlank(param.getFileName(), "attachment");
        try (InputStream inputStream = param.getInputStream()) {
            return parse(fileName, inputStream);
        } catch (IOException e) {
            throw new BusinessException("ai.attachment.parseFailed", new Object[]{fileName, e.getMessage()}, e);
        }
    }

    public ChatAttachment parse(AiLocalAttachmentParseRequest param) {
        if (param == null || StringUtils.isBlank(param.getFilePath())) {
            throw new BusinessException("ai.attachment.filePathRequired");
        }
        File file = new File(param.getFilePath().trim());
        if (!file.exists() || !file.isFile()) {
            throw new BusinessException("ai.attachment.fileNotFound");
        }
        String fileName = StringUtils.defaultIfBlank(param.getFileName(), file.getName());
        try (InputStream inputStream = new FileInputStream(file)) {
            return parse(fileName, inputStream);
        } catch (IOException e) {
            throw new BusinessException("ai.attachment.localParseFailed", new Object[]{file.getPath(), e.getMessage()}, e);
        }
    }

    public String buildStructuredContext(List<ChatAttachment> attachments) {
        if (CollectionUtils.isEmpty(attachments)) {
            return null;
        }
        StringBuilder builder = new StringBuilder(4096);

View on GitHub (pinned to 5ee1e990e7)

Solutions

  1. Ensure the caller sets param.setFilePath() to a non-blank, absolute server path before calling parse().
  2. If the renderer is uploading bytes rather than referencing a server path, call parse(AiAttachmentParseRequest) (the InputStream overload) instead of the local-path overload.
  3. Add a null/blank check on filePath in the controller or service caller and return a 400 with a clear field-level error before reaching the domain service.

Example fix

// before
AiLocalAttachmentParseRequest req = new AiLocalAttachmentParseRequest();
// filePath never set
service.parse(req);

// after
AiLocalAttachmentParseRequest req = new AiLocalAttachmentParseRequest();
req.setFilePath(uploadedTempPath);
if (StringUtils.isBlank(req.getFilePath())) {
    return ResponseEntity.badRequest().body("filePath is required");
}
service.parse(req);
Defensive patterns

Strategy: validation

Validate before calling

// caller-side guard before parse(AiLocalAttachmentParseRequest)
AiLocalAttachmentParseRequest param = /* ... */;
if (param == null || StringUtils.isBlank(param.getFilePath())) {
    return ResponseEntity.badRequest().body("filePath is required");
}
File f = new File(param.getFilePath().trim());
if (!f.isFile()) {
    return ResponseEntity.badRequest().body("file not found");
}
service.parse(param);

Prevention

When it happens

Trigger: Calling AiAttachmentService.parse(AiLocalAttachmentParseRequest) where param is null, or param.getFilePath() returns null/empty/whitespace-only. This path is used when the JCEF/desktop or web renderer submits a server-side file path rather than an uploaded stream.

Common situations: Frontend sends an AiLocalAttachmentParseRequest with filePath unset because the upload step failed silently; a serialized request lost the field; a test constructs the request object without setting filePath; the user submitted the form before the path was populated.

Related errors


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