iflytek/astron-agent · error · ValueError
Invalid group: . Valid options
Error message
Invalid group: {value}. Valid options: {valid_groups} What it means
Pydantic field_validator on the 'group' field of the ISE evaluation request model rejects any value outside ['pupil','youth','adult']. The error surfaces as a pydantic ValidationError when the request model is constructed.
Solutions
- Send group as one of 'pupil','youth','adult' (lowercase, no whitespace)
- Add value.strip().lower() normalization before model construction if input is user-supplied
- Check the error detail (loc=['group']) to confirm which field failed
Example fix
// before
req = IseEvaluateRequest(group='Adult', ...)
// after
value = raw_group.strip().lower()
assert value in ('pupil', 'youth', 'adult')
req = IseEvaluateRequest(group=value, ...) Defensive patterns
Strategy: validation
Validate before calling
if not isinstance(value, str) or value not in ('pupil', 'youth', 'adult'):
raise ValueError(f'invalid group: {value!r}') Try / catch
from pydantic import ValidationError
try:
req = IseEvaluateRequest(**payload)
except ValidationError as e:
for err in e.errors():
if err['loc'] == ('group',):
payload['group'] = 'adult'
req = IseEvaluateRequest(**payload) Prevention
- Send lowercase, whitespace-free enum values
- Document the three valid groups in the API schema
- Normalize with .strip().lower() before constructing the model
When it happens
Trigger: POSTing/constructing the ISE evaluation request with group='Child', group='', group=None (typed field) or any other non-member string.
Common situations: Case mismatch ('Adult'), trailing whitespace, or frontend sending a different taxonomy than the backend's three valid groups.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- mcpServerId and mcpServerUrl cannot both be empty
- toolName cannot be empty
- ragflow_ext is only allowed when ragType='Ragflow-RAG', got…
- The file address is incorrect
- Remote resource URL is malformed
AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12).
Data as JSON: /api/errors/f1b900a18225f4a7.
Report an issue: GitHub.
Appendix: source
Thrown at core/plugin/aitools/service/ise/ise_evaluate_service.py:43
"""ISE Input"""
audio_data: str # Base64 encoded audio data
text: str = "" # Optional text to be evaluated
language: str = "cn" # Language type: cn(Chinese)/en(English)
category: str = (
"read_sentence" # Evaluation type: read_syllable/read_word/read_sentence
)
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",View on GitHub (pinned to 5e758547a8)