iflytek/astron-agent · error · ServiceException
CodeEnums.ServiceParamsError
CodeEnums.ServiceParamsError
Error message
text不能为空
What it means
The Smart TTS service rejects a request whose `body.text` is missing, None, or an empty string before doing any work. Since text is the sole required input for text-to-speech synthesis, the service fails fast with ServiceParamsError to avoid a pointless (and costly) call to the iFlytek TTS backend. The check `if not body.text` treats empty strings and None identically.
Solutions
- Ensure the `text` field is populated with non-empty content in the request body before invoking the smart TTS endpoint.
- Add client-side validation on the caller (form/workflow node) that blocks empty or whitespace-only text with a friendlier message.
- If text comes from a previous pipeline step, log/inspect that step's output to find why it produced empty text.
- Consider trimming whitespace on the caller side and rejecting whitespace-only strings early so the user sees a clear validation error.
Example fix
// before
await api.post('/plugin/aitools/smart_tts', { vcn: 'xiaoyan', speed: 50 });
// after
const text = userInput.trim();
if (!text) throw new Error('Please provide text to synthesize');
await api.post('/plugin/aitools/smart_tts', { text, vcn: 'xiaoyan', speed: 50 }); Defensive patterns
Strategy: validation
Validate before calling
def can_call_smart_tts(body) -> bool:
return bool(body and getattr(body, 'text', None) and body.text.strip()) Type guard
def has_text(body) -> bool:
return isinstance(getattr(body, 'text', None), str) and body.text.strip() != '' Try / catch
try:
resp = await smart_tts_service(body, request)
except ServiceException as e:
if e.code == CodeEnums.ServiceParamsError:
return error_response('请输入需要合成的文本', 400)
raise Prevention
- Validate text is non-empty and non-whitespace in the UI/form before submitting.
- Add a shared request-preflight check for required fields in workflow nodes feeding TTS.
- Trim user input before constructing SmartTTSRequest.
When it happens
Trigger: Calling smart_tts_service with a SmartTTSRequest whose `text` field is None, empty string "", or a falsy value; e.g. POSTing to the smart-TTS endpoint with an omitted or blank `text` JSON field.
Common situations: Frontend sends the request before the user types anything; an upstream workflow node passes an empty LLM output as the TTS input; a caller strips/normalizes text and accidentally empties it; schema changes rename the field so text is never populated.
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
- Invalid lengthRange format
- Invalid separator format
- PARAMETER_ERROR
- PARAMS_ERROR
- The lengthRange must be an array of integers
AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12).
Data as JSON: /api/errors/6cbe70b96353759c.
Report an issue: GitHub.
Appendix: source
Thrown at core/plugin/aitools/service/smart_tts/smart_tts_service.py:91
path="/aitools/v1/smarttts",
query=None,
body=SmartTTSInput,
response=BaseResponse,
summary="Smart TTS",
description="Convert text to speech",
tags=["public_cn"],
deprecated=False,
)
async def smart_tts_service(
body: SmartTTSInput,
request: Request,
span: Optional[SpanLike] = None,
meter: Optional[Meter] = None,
node_trace: Optional[NodeTraceLog] = None,
) -> BaseResponse:
"""Smart TTS Service"""
if not body.text:
raise ServiceException.from_error_code(
CodeEnums.ServiceParamsError, extra_message="text不能为空"
)
url = os.getenv(TTS_URL_KEY, "")
credentials = get_iflytek_open_platform_credentials()
data = gen_data(credentials.app_id, body.text, body.vcn, body.speed)
audio_data = bytearray()
async with WebSocketClient(
url=url,
span=span,
auth="ASE",
app_id=credentials.app_id,
api_key=credentials.api_key,
api_secret=credentials.api_secret,
).start() as client:
await client.send(json.dumps(data))
View on GitHub (pinned to 5e758547a8)