iflytek/astron-agent · error · ValueError

audio_data cannot be empty

Error message

audio_data cannot be empty

What it means

Pydantic field_validator on ISE evaluate request: audio_data (the base64 evaluation audio) is empty, so the request model rejects it. Oral-assessment scoring cannot run without an audio payload — the request never reaches the ISE service.

Solutions

  1. Provide the base64-encoded audio bytes in audio_data
  2. Check upstream recording/upload code for empty files
  3. Fail fast in the caller before sending the request when audio is empty

Example fix

// before
req = IseEvaluateRequest(audio_data='', text=text)
// after
if not audio_bytes:
    raise RuntimeError('no audio recorded')
req = IseEvaluateRequest(audio_data=base64.b64encode(audio_bytes).decode(), text=text)
Defensive patterns

Strategy: validation

Validate before calling

if not audio_data:
    raise ValueError('audio_data is required before calling the ISE API')

Try / catch

try:
    req = IseEvaluateRequest(audio_data=audio_data, text=text)
except ValidationError as e:
    if any('cannot be empty' in str(err['msg']) for err in e.errors()):
        return error_response('please provide a recording')

Prevention

When it happens

Trigger: Constructing the ISE evaluation request with audio_data='' or a falsy value.

Common situations: Recording produced a zero-byte file; the client-side uploader failed silently; a default '' was left in a form/model.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


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

Appendix: source

Thrown at core/plugin/aitools/service/ise/ise_evaluate_service.py:51

    group: str = (
        "adult"  # Age group: pupil(Kindergarten)/youth(Elementary)/adult(Adult)
    )

    @field_validator("group")
    @classmethod
    def validate_group(cls, value: str) -> str:
        """Validate group"""
        valid_groups = ["pupil", "youth", "adult"]
        if value not in valid_groups:
            raise ValueError(f"Invalid group: {value}. Valid options: {valid_groups}")
        return value

    @field_validator("audio_data")
    @classmethod
    def validate_audio_data(cls, value: str) -> str:
        """Validate audio_data"""
        if not value:
            raise ValueError("audio_data cannot be empty")
        try:
            base64.b64decode(value)
        except Exception as exc:
            raise ValueError("audio_data must be valid base64 encoded string") from exc
        return value


@api_service(
    method="POST",
    path="/aitools/v1/ise",
    query=None,
    body=ISEInput,
    response=BaseResponse,
    summary="ISE Evaluation",
    description="ISE Evaluation",
    tags=["public_cn"],
    deprecated=True,
)

View on GitHub (pinned to 5e758547a8)