{"record":{"id":"dce5a8af95370a86","repo":"iflytek/astron-agent","slug":"group-valid-groups","errorCode":null,"errorMessage":"无效的年龄组参数: {group}，有效选项: {valid_groups}","messagePattern":"无效的年龄组参数: (.+?)，有效选项: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"core/plugin/aitools/service/ise/ise_client.py","lineNumber":347,"sourceCode":"        app_id: str,\n        api_key: str,\n        api_secret: str,\n        audio_data: bytes,\n        text: str = \"\",\n        language: str = \"cn\",\n        category: str = \"read_sentence\",\n        group: str = \"adult\",\n    ):\n        self.app_id = app_id\n        self.api_key = api_key\n        self.api_secret = api_secret\n        self.audio_data = audio_data\n        self.text = text\n\n        # Validate the age group parameter.\n        valid_groups = [\"pupil\", \"youth\", \"adult\"]\n        if group not in valid_groups:\n            raise ValueError(f\"无效的年龄组参数: {group}，有效选项: {valid_groups}\")\n\n        # Set up the engine type parameter.\n        ent = \"cn_vip\" if language == \"cn\" else \"en_vip\"\n\n        # Set up the public parameters.\n        self.common_args = {\"app_id\": self.app_id}\n\n        # Business parameters - according to the official document format\n        self.business_args = {\n            \"category\": category,  # Evaluation category\n            \"sub\": \"ise\",  # Service type\n            \"ent\": ent,  # Engine type\n            \"cmd\": \"ssb\",  # Command\n            \"auf\": \"audio/L16;rate=16000\",  # Audio format\n            \"aue\": \"raw\",  # Audio encoding\n            \"text\": self._encode_text() if text else \"\",  # Evaluation text\n            \"tte\": \"utf-8\",  # Text encoding\n            \"rstcd\": \"utf8\",  # Result encoding","sourceCodeStart":329,"sourceCodeEnd":365,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/core/plugin/aitools/service/ise/ise_client.py#L329-L365","documentation":"The ISE (Intelligent Speech Evaluation) client constructor validates the age group parameter before building the request. Only 'pupil', 'youth', and 'adult' are supported engine profiles, so any other value raises a ValueError immediately at object creation.","triggerScenarios":"Calling the ISE client __init__ with group set to anything other than 'pupil'/'youth'/'adult' — e.g. passing a localized label, None, or an empty string.","commonSituations":"Mapping an end-user-facing age selection (Chinese labels, numbers like 'child') directly to the API parameter; forgetting to normalize user input to one of the three enum-like strings.","solutions":["Pass exactly one of 'pupil', 'youth', 'adult' as the group parameter","Normalize/validate caller-supplied input against the allowed list before constructing the client","Add a mapping layer from your app's own age categories to the supported values"],"exampleFix":"// before\nclient = IseClient(group='child', audio_data=audio, text=text, language='en')\n// after\nmapping = {'child': 'pupil', 'teen': 'youth', 'grown-up': 'adult'}\ngroup = mapping.get(user_group, user_group)\nif group not in ('pupil', 'youth', 'adult'):\n    raise ValueError(f'unsupported group: {group}')\nclient = IseClient(group=group, audio_data=audio, text=text, language='en')","handlingStrategy":"validation","validationCode":"VALID_GROUPS = ('pupil', 'youth', 'adult')\nif group not in VALID_GROUPS:\n    raise ValueError(f'group must be one of {VALID_GROUPS}, got {group!r}')","typeGuard":null,"tryCatchPattern":"try:\n    client = IseClient(group=group, audio_data=audio, text=text, language=lang)\nexcept ValueError as e:\n    log.error('invalid ISE group: %s', e)\n    group = 'adult'\n    client = IseClient(group=group, audio_data=audio, text=text, language=lang)","preventionTips":["Keep a single VALID_GROUPS constant shared by all ISE code paths","Normalize user-facing labels to enum values at the API boundary","Cover the group mapping with unit tests"],"tags":["validation","python","speech-evaluation"],"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"}