Skip to content

Conversation

@kaleev
Copy link
Contributor

@kaleev kaleev commented Apr 28, 2025

Motivation and Context

This pull request fixes an issue with the ReadBuffer functionality by ensuring that empty lines are properly skipped during input processing. A new test case has been added to validate this behavior.

How Has This Been Tested?

The ReadBuffer threw exception on empty message which leaded to connection closing.

Breaking Changes

no

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

@kaleev
Copy link
Contributor Author

kaleev commented Apr 28, 2025

@e5l, could you please take a look?

@e5l e5l requested review from Copilot and e5l and removed request for Copilot April 29, 2025 12:06
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request fixes an issue with the ReadBuffer functionality by properly skipping empty lines during input processing. The changes include:

  • Updating ReadBuffer to return null for empty lines instead of an empty string.
  • Adding a new test case to ensure the empty line behavior is correctly handled.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/jvmTest/kotlin/shared/ReadBufferTest.kt Added a test to validate that an empty line returns null.
src/commonMain/kotlin/io/modelcontextprotocol/kotlin/sdk/shared/ReadBuffer.kt Modified the empty line handling to return null after skipping the newline.
Comments suppressed due to low confidence (1)

src/commonMain/kotlin/io/modelcontextprotocol/kotlin/sdk/shared/ReadBuffer.kt:27

  • Changing from returning an empty string to null on an empty line fixes the issue reported with the ReadBuffer, but please ensure that this behavior is consistent with the overall contract of readMessage() and doesn’t cause side effects elsewhere.
return null

Copy link
Contributor

@e5l e5l left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @kaleev, thanks for the PR. LGTM

@e5l e5l enabled auto-merge (squash) April 29, 2025 12:07
@e5l e5l merged commit dc5c155 into modelcontextprotocol:main Apr 29, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants