Repository navigation
fix(google-genai): extract enum name for finish reason - #1975
todkarsant wants to merge 1 commit into
Conversation
FinishReason is a (str, Enum) subclass; str() on it gives "FinishReason.MAX_TOKENS" instead of "MAX_TOKENS". The OTel finish_reason_map then misses and the raw repr leaks into spans and output messages. Use the enum's .name attribute instead. Fixes openlit#1899
Reviewer's GuideImplementationAdd a helper that extracts an enum’s plain name (or falls back to its string value), then use it to normalize finish reasons in streamed and chat responses.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
PR Summary by QodoFix Google GenAI finish-reason enum handling
AI Description
Merge Risk
|
Code Review by Qodo🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)
Great, no issues found!Qodo reviewed your code and found no material issues that require reviewTip of the day💡 Did you know, you can turn on the rule miner and Qodo learns your standards from review history |
Linked issuesChecked at commit 70bc5b2 #1899 Bug: google-genai spans record the finish reason as "FinishReason.MAX_TOKENS" instead of its value · 3 of 3 met
|
There was a problem hiding this comment.
Hey - I've reviewed your changes and they look great!
Sourcery assessment
Needs a human reviewer. If the conversion is wrong, spans will carry an incorrect finish-reason value in exported telemetry. Reverting restores future spans, but it cannot correct telemetry already recorded; the impact is limited to those records.
Summary
FinishReasonis a(str, Enum)subclass;str()on it gives"FinishReason.MAX_TOKENS"instead of"MAX_TOKENS"finish_reason_mapthen misses and the raw repr leaks intogen_ai.response.finish_reasonsand output messages.nameattribute, with a fallback for plain stringsFixes #1899
Summary by Sourcery
Bug Fixes: