666ghj/MiroFish · error · RuntimeError

batch.create returned no batch_id

Error message

batch.create returned no batch_id

What it means

Raised in the validation script's main flow when client.batch.create succeeds but batch.batch_id is falsy. Without a batch_id the script cannot add items, process, or list the batch, so it aborts immediately. It is a RuntimeError guarding an unexpected SDK/API response shape.

Source

Thrown at backend/scripts/validate_zep_cloud_integration.py:517

                "error_type": type(error).__name__,
                "status_code": _status_code(error),
            }
            raise

        builder.set_ontology(graph_id, ONTOLOGY)
        print("[zep-deep] ontology set", flush=True)

        operation_id = f"deep-validation-{stamp}"
        batch = client.batch.create(
            metadata={
                "mirofish_operation_id": operation_id,
                "graph_id": graph_id,
                "suite": "zep_deep_validation",
            }
        )
        batch_id = batch.batch_id
        if not batch_id:
            raise RuntimeError("batch.create returned no batch_id")
        result["batch_id"] = batch_id

        added_details: list[Any] = []
        batch_items = [
            _episode_to_batch_item(graph_id, item, index)
            for index, item in enumerate(BASELINE_EPISODES)
        ]
        for start in range(0, len(batch_items), 4):
            added_details.extend(
                client.batch.add(batch_id=batch_id, items=batch_items[start : start + 4])
            )
        client.batch.process(batch_id=batch_id)
        print(f"[zep-deep] batch submitted items={len(batch_items)}", flush=True)

        submission = BatchSubmission(
            batch_id=batch_id,
            operation_id=operation_id,
            episode_uuids=[_uuid(item) for item in added_details if _uuid(item)],

View on GitHub (pinned to b5b53acc57)

Solutions

  1. Align the zep-cloud package version with the API (upgrade to latest, or pin a known-good release).
  2. Debug once by printing type(batch) and vars(batch) to spot renamed fields.
  3. If mocking, make the fake batch.create return an object with a non-empty batch_id.
Defensive patterns

Strategy: try-catch

Type guard

def batch_has_id(batch: Any) -> bool:
    return bool(getattr(batch, "batch_id", None))

Try / catch

try:
    batch = client.batch.create(metadata=meta)
    if not batch.batch_id:
        raise RuntimeError("batch.create returned no batch_id")
except RuntimeError as e:
    if "no batch_id" in str(e):
        logger.error("zep-cloud response shape changed; check SDK version")
        raise
    raise

Prevention

When it happens

Trigger: client.batch.create(metadata=...) returning a response with a None/empty batch_id — SDK-API version mismatch after upgrading zep-cloud, a renamed field, or a stubbed client in tests.

Common situations: zep-cloud SDK upgraded beyond the API's response format (or vice versa); partially mocked clients in CI constructing a Batch without batch_id.

Related errors


AI-assisted analysis of 666ghj/MiroFish@b5b53acc57 (2026-08-14). Data as JSON: /api/errors/49e63fed4c51451a. Report an issue: GitHub.