iflytek/astron-agent · error · ValueError

File upload failed: no document returned

Error message

File upload failed: no document returned

What it means

Raised in _process_document_upload (core/knowledge/service/impl/ragflow_strategy.py:247) when the RAGFlow upload endpoint responds successfully but the returned document list is empty, so no document id can be extracted. This means the upload call did not fail at transport level, yet RAGFlow did not register the document.

Solutions

  1. Verify the dataset_id exists immediately before upload (GET /api/v1/datasets/{id}) and recreate it if missing.
  2. Check the file being uploaded is non-empty and readable — log content length before calling upload.
  3. Inspect the raw upload response in logs to see whether RAGFlow returned a per-file error code.
  4. Confirm the RAGFlow instance/storage (MinIO/S3) is healthy and has free quota for new documents.

Example fix

// before: upload with unverified dataset
doc_id = await strategy._process_document_upload(file, dataset_id)

// after: guard before uploading
info = await ragflow_client.get_dataset(dataset_id)
if info is None:
    dataset_id = await RagflowUtils.ensure_dataset("default")
if not file_content:
    raise ValueError("Refusing to upload empty file")
doc_id = await strategy._process_document_upload(file, dataset_id)
Defensive patterns

Strategy: validation

Validate before calling

# pre-upload guards
info = await ragflow_client.get_dataset(dataset_id)
if info is None:
    raise ValueError(f"dataset {dataset_id} does not exist")
file_content, filename = await RagflowUtils.process_file(file_input)
if not file_content:
    raise ValueError(f"refusing to upload empty file {filename}")

Type guard

def upload_response_has_doc(resp) -> bool:
    return bool(resp) and hasattr(resp[0], "id")

Try / catch

try:
    doc_id = await strategy._process_document_upload(file, dataset_id)
except ValueError as e:
    logger.error("upload produced no document for dataset=%s: %s", dataset_id, e)
    raise CustomException(CodeEnum.RAGFLOW_RAGError, str(e)) from e

Prevention

When it happens

Trigger: ragflow_client.upload_document_to_dataset returns an empty list or None while HTTP status is 200 — e.g. the dataset_id does not exist (RAGFlow sometimes returns an empty data list instead of an error), the file content is empty, or the RAGFlow client SDK silently swallows a per-file failure and returns an empty batch result.

Common situations: Dataset deleted between resolution and upload (race condition); uploading a zero-byte or unreadable file; dataset id belongs to a different RAGFlow tenant so the server no-ops; RAGFlow SDK version where upload returns [] on quota exceeded without raising.

Understand the failure class

Background: "empty response", "returned no data", "empty embeddings": what HTTP 200-with-empty-body errors mean across libraries — this error's family across 36 libraries.

Related errors


AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12). Data as JSON: /api/errors/11a10458c2d9c8a4. Report an issue: GitHub.

Appendix: source

Thrown at core/knowledge/service/impl/ragflow_strategy.py:247

        """Process document upload and return document ID."""
        file_content, filename = await RagflowUtils.process_file(file_input)
        logger.info(
            "File processing completed: %s, size: %d bytes",
            filename,
            len(file_content),
        )

        upload_response = await ragflow_client.upload_document_to_dataset(
            dataset_id=dataset_id, file_content=file_content, filename=filename
        )

        if upload_response and len(upload_response) > 0:
            doc_object = upload_response[0]
            doc_id = doc_object.id
            logger.info("Document uploaded successfully, ID: %s", doc_id)
            return doc_id
        else:
            raise ValueError("File upload failed: no document returned")

    async def _handle_document_parsing(
        self, dataset_id: str, doc_id: str, parser_config: Dict[str, Any]
    ) -> None:
        """Configure a document, trigger parsing, and wait for completion.

        Only parser parameters are updated here. RAGFlow selects specialized
        parsers for formats such as images, presentations, and email during
        upload; forcing every document back to ``naive`` would either discard
        that selection or make the update fail for visual documents.
        """
        logger.info(
            "Configuring RAGFlow document parser: dataset=%s doc=%s "
            "chunk_token_num=%s",
            dataset_id,
            doc_id,
            parser_config.get("chunk_token_num"),
        )

View on GitHub (pinned to 5e758547a8)