Skip to content

fix: evaluate client transport state error message - #1132

Open
mvanhorn wants to merge 1 commit into
modelcontextprotocol:mainfrom
mvanhorn:fix/1083-client-transport-state-error-message
Open

mvanhorn wants to merge 1 commit into
modelcontextprotocol:mainfrom
mvanhorn:fix/1083-client-transport-state-error-message

Conversation

@mvanhorn

Copy link
Copy Markdown

Motivation and Context

Callers checking an unexpected transport state receive an exception containing a function representation instead of the expected and observed states. Custom error messages are never evaluated. AbstractClientTransport.checkState returns lazyMessage itself from the check failure block instead of invoking it with actualState.

Invoke lazyMessage(actualState) when the state check fails. Add regression tests for the default message, custom message evaluation exactly once with the observed state, skipped evaluation when the state matches, and formatting after a forced state change.

Fixes #1083

How Has This Been Tested?

Ran ./gradlew test locally on macOS for the kotlin-sdk AbstractClientTransport change; it passed.
./gradlew --no-daemon :kotlin-sdk-core:testClasses failed because the requested task does not exist; no tests ran from this command.
./gradlew test completed successfully, but the transcript does not show the core JVM regression tests running.

Breaking Changes

Covered in the summary above.

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
    Nothing in the kotlin-sdk AbstractClientTransport change to kotlin-sdk-core/src/commonMain/kotlin/io/modelcontextprotocol/kotlin/sdk/shared/AbstractClientTransport.kt backs it.
  • I have added or updated documentation as needed
    The kotlin-sdk AbstractClientTransport change to kotlin-sdk-core/src/commonMain/kotlin/io/modelcontextprotocol/kotlin/sdk/shared/AbstractClientTransport.kt touches no documentation.

Additional context

Nothing beyond what is described above.

Invoke lazyMessage(actualState) when the state check fails. Add
regression tests for the default message, custom message evaluation
exactly once with the observed state, skipped evaluation when the state
matches, and formatting after a forced state change.

Fixes modelcontextprotocol#1083

@jetbrains-air jetbrains-air Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nice, focused fix with solid regression coverage — approving!


Produced by Air Automations. Name: Code review / Run: https://air.jetbrains.cloud/org/05cf1a7f-6ab5-713b-abd3-29d0c8a05e2d/automations/409567ec-d3a7-40ac-ba95-8518ec577ac2?run=d57e2c1c-18eb-4800-a86d-ab5887e9577f

This branch has not been deployed

No deployments
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.

AbstractClientTransport.checkState builds a broken error message

1 participant