iflytek/astron-agent · error · CustomException

MissingParameter

MissingParameter

Error message

chunks parameter cannot be empty

What it means

chunks_save validates the chunks payload with check_not_empty; an empty chunks list raises 'chunks parameter cannot be empty' because saving zero chunks would be a no-op that likely signals an upstream chunking failure.

Solutions

  1. Guard the caller: skip chunks_save entirely when the chunk list is empty.
  2. Fix the splitting/production step so a non-empty document yields at least one chunk.
  3. Validate request payload on the API layer to reject empty chunks earlier with a clearer message.
  4. If saving zero chunks is legitimate, change the caller to a no-op instead of invoking the API.

Example fix

// before
chunks = split_document(doc)  # may return []
await strategy.chunks_save(docId=doc_id, chunks=chunks, dataset_id=ds)
// after
chunks = split_document(doc)
if not chunks:
    logger.info("No chunks to save for %s, skipping", doc_id)
    return
await strategy.chunks_save(docId=doc_id, chunks=chunks, dataset_id=ds)
Defensive patterns

Strategy: validation

Validate before calling

if not chunks:
    logger.info("no chunks for %s; skipping save", doc_id)
    return
await strategy.chunks_save(docId=doc_id, chunks=chunks, dataset_id=ds)

Type guard

def has_chunks(chunks) -> bool:
    return isinstance(chunks, list) and len(chunks) > 0

Try / catch

try:
    await strategy.chunks_save(docId=doc_id, chunks=chunks, dataset_id=ds)
except CustomException as e:
    if "chunks parameter cannot be empty" in str(e):
        logger.warning("empty chunk batch submitted for %s", doc_id)
    else:
        raise

Prevention

When it happens

Trigger: chunks_save called with chunks=None, chunks=[], or a non-list value; upstream pipeline produced zero chunks from an empty/blank document.

Common situations: Empty document passed through a splitter yielding no segments; frontend submitted the save form without chunk data; a transformation step dropped all items silently.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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

Appendix: source

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

        Returns:
            List of save results in format:
            [
                {
                    "id": "chunk_id",
                    "datasetId": "dataset_id",
                    "fileId": "doc_id",
                    "createTime": "2025-09-15 14:41:19",
                    "updateTime": "2025-09-15 14:41:19",
                    "chunkType": "RAW",
                    "content": "chunk content",
                    "dataIndex": 0.0,
                    "imgReference": {}
                }
            ]
        """
        if not check_not_empty(chunks):
            logger.error("Chunks list is empty or invalid")
            raise CustomException(
                CodeEnum.MissingParameter, "chunks parameter cannot be empty"
            )

        logger.info(
            f"Starting chunk save request: docId={docId}, chunks_count={len(chunks)}"
        )

        try:
            dataset_id = await self._validate_chunks_save_config(
                docId, dataset_id=kwargs.get(_DATASET_ID_KWARG)
            )
            logger.info(f"Using dataset: {dataset_id}")

            await self._validate_document_exists(dataset_id, docId)

            existing_chunks = await self._get_existing_chunks(dataset_id, docId)

            current_time = time.strftime("%Y-%m-%d %H:%M:%S")

View on GitHub (pinned to 5e758547a8)