fix: Fix langfuse tracer when input messages is None#3324
Merged
Conversation
Contributor
Coverage report (langfuse)Click to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||
sjrl
commented
May 18, 2026
| if key.endswith(".input"): | ||
| if "messages" in value: | ||
| messages = [m.to_openai_dict_format(require_tool_call_ids=False) for m in value["messages"]] | ||
| messages = [m.to_openai_dict_format(require_tool_call_ids=False) for m in (value.get("messages") or [])] |
Contributor
Author
There was a problem hiding this comment.
We do value.get("messages") or [] to catch the case that messages key is present in value but it returns None. Doing value.get("messages", []) would not catch it since the back up [] only occurs if messages is missing.
anakin87
approved these changes
May 18, 2026
Member
anakin87
left a comment
There was a problem hiding this comment.
👍
(I'm not a big fan of the LLM component 😃)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related Issues
Proposed Changes:
The LLM component accepts
messages=Noneas valid input which can break the Langfuse Tracer since it always assumes that ifmessagesis present that it's always alist[ChatMessage]. This PR updates to handle theNonecase.We also add the same guard for
repliesreturning asNone. This is not a known case but done for safety.How did you test it?
Added new unit tests.
Notes for the reviewer
Checklist
fix:,feat:,build:,chore:,ci:,docs:,style:,refactor:,perf:,test:.