fix(gemini,groq): include finish reason in unhandled finish reason exceptions#994
Conversation
…eason exceptions The default branch in the finish reason match threw a generic "unhandled finish reason" message without including what the actual reason was, making debugging difficult. Now includes both the mapped FinishReason enum value and the raw provider finish reason string. Affects Gemini Text, Gemini Structured, and Groq Text handlers. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Additional context: unhandled finish reasonsWhile investigating this fix, I catalogued the complete set of finish reasons each provider can return vs what's currently handled. GeminiGemini's
Additionally, 8 values that are in the
GroqGroq only has 4 finish reasons ( These are potential follow-up items — this PR just ensures the exception messages are useful for debugging when any of them are encountered. Sources: Google AI REST v1, Vertex AI REST v1, Groq API reference |
Description
Enriches the default
PrismExceptioninGemini\Handlers\Text,Gemini\Handlers\Structured, andGroq\Handlers\Textto include both the mappedFinishReasonenum value and the raw provider finish reason string — matching the approach already used in OpenAI handlers (PR #941).Previously threw a generic
"Gemini: unhandled finish reason"with no indication of what the actual reason was (e.g.SAFETY,LANGUAGE, etc.). Now throws'Gemini: unhandled finish reason "content-filter" (raw: SAFETY)'.Relates to #205.
Changes:
src/Providers/Gemini/Handlers/Text.php— enriched default exception with sprintfsrc/Providers/Gemini/Handlers/Structured.php— samesrc/Providers/Groq/Handlers/Text.php— sameBreaking Changes
None — only changes exception message strings in error paths.