{"record":{"id":"3734a292109b2ef7","repo":"iflytek/astron-agent","slug":"open-ai-request-error-no-valid-content-to-send-to-google-api","errorCode":"OPEN_AI_REQUEST_ERROR","errorMessage":"No valid content to send to Google API","messagePattern":"No valid content to send to Google API","errorType":"error_code","errorClass":"CustomException","httpStatus":null,"severity":"error","filePath":"core/workflow/infra/providers/llm/google/google_chat_llm.py","lineNumber":253,"sourceCode":"\n        Args:\n            url: API endpoint URL (used for custom Google-compatible endpoints)\n            user_message: List of user messages to send\n            extra_params: Additional parameters for the API call\n            span: OpenTelemetry span for tracing\n            timeout: Request timeout in seconds\n\n        Yields:\n            LLMResponse objects containing normalized API responses\n        \"\"\"\n        # Convert messages to Google GenAI format\n        contents, system_instruction = await self._convert_messages_to_genai_format(\n            user_message\n        )\n\n        # Validate we have content to send\n        if not contents:\n            raise CustomException(\n                err_code=CodeEnum.OPEN_AI_REQUEST_ERROR,\n                err_msg=\"No valid content to send to Google API\",\n                cause_error=\"Empty content after conversion\",\n            )\n\n        # Build generation configuration\n        generation_config = GenerateContentConfig(\n            max_output_tokens=self.max_tokens,\n            temperature=self.temperature,\n        )\n\n        # Add system instruction if present\n        if system_instruction:\n            generation_config.system_instruction = system_instruction\n\n        # Handle extra parameters\n        if extra_params:\n            # Map common parameters to GenerateContentConfig fields","sourceCodeStart":235,"sourceCodeEnd":271,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/core/workflow/infra/providers/llm/google/google_chat_llm.py#L235-L271","documentation":"In GoogleChatAI._recv_messages, messages are converted to the google-genai 'contents' + system_instruction format. If the conversion produces an empty contents list (no text/parts survived), the provider raises CustomException(OPEN_AI_REQUEST_ERROR, 'No valid content to send to Google API') rather than sending a request Gemini would reject. It indicates the input message list contained nothing convertible (e.g. only tool messages, or messages with empty content).","triggerScenarios":"Calling achat/_recv_messages with a user_message whose converted contents list is empty: all messages have None/empty string content, only unsupported roles are present, or content parts were all filtered out during _convert_messages_to_genai_format.","commonSituations":"A workflow node passes an empty prompt (upstream variable not filled in), a chat history containing only assistant/system messages with no user text, or content stored in a field the converter ignores.","solutions":["Inspect the messages passed to achat and ensure at least one message has non-empty text content (typically a user message).","Fix the upstream workflow node so the prompt variable is actually populated before invoking the LLM.","Extend _convert_messages_to_genai_format if valid content lives in a field/role it currently skips.","Add a caller-side guard that raises a clearer business error when the assembled prompt is empty."],"exampleFix":"// before\nmsgs = [{'role': 'assistant', 'content': ''}]\nawait llm.achat(msgs)\n// after\nif not any((m.get('content') or '').strip() for m in msgs):\n    raise ValueError('prompt is empty: refusing to call LLM')\nawait llm.achat(msgs)","handlingStrategy":"validation","validationCode":"def has_sendable_content(messages):\n    return any(\n        isinstance(m, dict) and str(m.get('content') or '').strip()\n        and m.get('role') not in (None, 'tool')\n        for m in messages\n    )\n","typeGuard":null,"tryCatchPattern":"try:\n    async for chunk in llm.achat(messages):\n        handle(chunk)\nexcept CustomException as e:\n    if 'No valid content' in e.err_msg:\n        raise PromptError('workflow produced an empty prompt') from e\n    raise\n","preventionTips":["Validate the assembled prompt is non-empty before invoking the LLM node","Check upstream workflow variables are bound (no blank placeholders)","Log message counts/lengths before each LLM call","Keep converters strict and log skipped messages in _convert_messages_to_genai_format"],"tags":["google","gemini","llm","empty-input","validation"],"backgroundTag":"empty-required-field","analyzedSha":"5e758547a83371a5a4b29dadf4ac03e8dd527635","analyzedAt":"2026-09-12T08:03:51.356Z","contentChangedAt":"2026-09-12T08:03:51.356Z","schemaVersion":2},"datasetVersion":"2026-09-19T17:17:19.058Z"}