Response error keyword argument#107
Merged
koic merged 1 commit intomodelcontextprotocol:mainfrom Aug 20, 2025
Merged
Conversation
rtymchyk
approved these changes
Aug 13, 2025
joshua-zingale
approved these changes
Aug 15, 2025
koic
reviewed
Aug 17, 2025
koic
reviewed
Aug 17, 2025
e26451d to
10aa055
Compare
koic
reviewed
Aug 18, 2025
|
|
||
| response = Response.new(content) | ||
| assert_equal content, response.content | ||
| refute response.error? |
Member
There was a problem hiding this comment.
Can you split it into three tests, each independently executable per assertion group?
koic
reviewed
Aug 18, 2025
| actual = response.to_h | ||
| assert_equal [:content, :isError].sort, actual.keys.sort | ||
| assert_equal content, actual[:content] | ||
| assert actual[:isError] |
Member
There was a problem hiding this comment.
Can you split it into two tests, each independently executable per assertion group?
koic
reviewed
Aug 18, 2025
test/mcp/tool/response_test.rb
Outdated
| assert response.error? | ||
|
|
||
| response = Response.new(nil, error: false) | ||
| refute response.error? |
Member
There was a problem hiding this comment.
Can you split it into two tests, each independently executable per assertion?
koic
reviewed
Aug 18, 2025
test/mcp/tool/response_test.rb
Outdated
|
|
||
| response = Response.new(nil, error: false) | ||
| refute response.error? | ||
| end |
Member
There was a problem hiding this comment.
Can you move this test "#error?" do (L46-L52) before test "#to_h" do (L27) ?
Member
|
Since the purpose of these changes is singular, please squash them into a single commit. |
Both the combination of positional argument and naming does not feel like Ruby. This change makes `is_error` argument a keyword argument called `error`. Thanks to this, the usage is more self-explanatory: ```ruby response = Response.new([], error: true) ```
10aa055 to
6689db2
Compare
Contributor
Author
|
@koic Addressed your feedback. |
koic
approved these changes
Aug 19, 2025
atesgoral
approved these changes
Aug 19, 2025
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.
The positional argument and naming is a bit awkward, and feels unnatural. Let's instead follow the Ruby style and add an
error:keyword argument.Before
After
Motivation and Context
How Has This Been Tested?
Unit tests
Breaking Changes
For anyone using the positional argument, this is a breaking change.
Types of changes
Checklist
Additional context
I'm happy to remove the second commit that introduces the
ErrorResponseclass. I do find it's usage a nicer approach that moves the decision to the caller, but also I can see how it adds some unnecessary boilerplate. Let me know what you think!