fix(mcp): skip conversation link when conversation_id is None#12941
Merged
malhotra5 merged 2 commits intoOpenHands:mainfrom Feb 19, 2026
Merged
Conversation
When PRs are created via MCP tools without a valid conversation context, the conversation_id can be None, resulting in broken links pointing to /conversations/None in PR descriptions. This adds an early return in get_conversation_link when conversation_id is None or empty, preventing the broken link from being appended. Fixes OpenHands#12832 Signed-off-by: machov <mv1742@nyu.edu>
Collaborator
all-hands-bot
left a comment
There was a problem hiding this comment.
Clean fix! The early return properly handles the edge case, type hints are correct, and the test coverage is thorough.
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.
Fixes #12832
When PRs are created via MCP tools without a valid conversation context (e.g., from external MCP clients or contexts where
X-OpenHands-ServerConversation-IDheader is missing), theconversation_idcan beNone. This results in broken links pointing to/conversations/Nonein PR descriptions.Changes
openhands/server/routes/mcp.py: Added an early return inget_conversation_linkwhenconversation_idisNoneor empty, and updated the type hint tostr | None.tests/unit/server/routes/test_mcp_routes.py: Added test covering bothNoneand empty stringconversation_idcases, verifying the body is returned unchanged andget_useris never called.