{"record":{"id":"f1b900a18225f4a7","repo":"iflytek/astron-agent","slug":"invalid-group-value-valid-options-valid-groups","errorCode":null,"errorMessage":"Invalid group: {value}. Valid options: {valid_groups}","messagePattern":"Invalid group: (.+?)\\. Valid options: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"core/plugin/aitools/service/ise/ise_evaluate_service.py","lineNumber":43,"sourceCode":"    \"\"\"ISE Input\"\"\"\n\n    audio_data: str  # Base64 encoded audio data\n    text: str = \"\"  # Optional text to be evaluated\n    language: str = \"cn\"  # Language type: cn(Chinese)/en(English)\n    category: str = (\n        \"read_sentence\"  # Evaluation type: read_syllable/read_word/read_sentence\n    )\n    group: str = (\n        \"adult\"  # Age group: pupil(Kindergarten)/youth(Elementary)/adult(Adult)\n    )\n\n    @field_validator(\"group\")\n    @classmethod\n    def validate_group(cls, value: str) -> str:\n        \"\"\"Validate group\"\"\"\n        valid_groups = [\"pupil\", \"youth\", \"adult\"]\n        if value not in valid_groups:\n            raise ValueError(f\"Invalid group: {value}. Valid options: {valid_groups}\")\n        return value\n\n    @field_validator(\"audio_data\")\n    @classmethod\n    def validate_audio_data(cls, value: str) -> str:\n        \"\"\"Validate audio_data\"\"\"\n        if not value:\n            raise ValueError(\"audio_data cannot be empty\")\n        try:\n            base64.b64decode(value)\n        except Exception as exc:\n            raise ValueError(\"audio_data must be valid base64 encoded string\") from exc\n        return value\n\n\n@api_service(\n    method=\"POST\",\n    path=\"/aitools/v1/ise\",","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/core/plugin/aitools/service/ise/ise_evaluate_service.py#L25-L61","documentation":"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.","triggerScenarios":"POSTing/constructing the ISE evaluation request with group='Child', group='', group=None (typed field) or any other non-member string.","commonSituations":"Case mismatch ('Adult'), trailing whitespace, or frontend sending a different taxonomy than the backend's three valid groups.","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"],"exampleFix":"// before\nreq = IseEvaluateRequest(group='Adult', ...)\n// after\nvalue = raw_group.strip().lower()\nassert value in ('pupil', 'youth', 'adult')\nreq = IseEvaluateRequest(group=value, ...)","handlingStrategy":"validation","validationCode":"if not isinstance(value, str) or value not in ('pupil', 'youth', 'adult'):\n    raise ValueError(f'invalid group: {value!r}')","typeGuard":null,"tryCatchPattern":"from pydantic import ValidationError\ntry:\n    req = IseEvaluateRequest(**payload)\nexcept ValidationError as e:\n    for err in e.errors():\n        if err['loc'] == ('group',):\n            payload['group'] = 'adult'\n    req = IseEvaluateRequest(**payload)","preventionTips":["Send lowercase, whitespace-free enum values","Document the three valid groups in the API schema","Normalize with .strip().lower() before constructing the model"],"tags":["pydantic","validation","python"],"backgroundTag":"invalid-enum-value","analyzedSha":"5e758547a83371a5a4b29dadf4ac03e8dd527635","analyzedAt":"2026-09-12T08:03:51.356Z","contentChangedAt":"2026-09-12T08:03:51.356Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}