Repository navigation
[Server] Pass an explicit null to a nullable tool parameter with a default - #642
Open
bigdevlarry wants to merge 1 commit into
Conversation
bigdevlarry
requested review from
CodeWithKyrian,
Nyholm,
chr-hertel and
soyuka
as code owners
October 30, 2026 20:15
…fault Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
bigdevlarry
force-pushed
the
fix-nullable-tool-parameter-with-a-default-ignores-an-explicit-null-argument
branch
from
October 30, 2026 22:13
9001730 to
adbbcfb
Compare
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues were identified for the change preserving explicit null arguments while retaining defaults for omitted parameters.
No open issues 🎉
What changed in this PR
Fixes issue #640 by preserving explicit null values for nullable tool parameters in ReferenceHandler, while retaining default values when arguments are omitted.
Changes:
- Distinguishes an explicitly supplied
nullfrom a missing argument for nullable parameters. - Adds a regression test covering both explicit
nulland omitted arguments. - Documents the fix in the changelog.
| File | Description |
|---|---|
tests/Unit/Capability/Registry/ReferenceHandlerTest.php |
Tests explicit null handling and preservation of defaults for omitted arguments. |
src/Capability/Registry/ReferenceHandler.php |
Accepts present argument keys with null values when the parameter allows null. |
CHANGELOG.md |
Records the nullable tool parameter fix. |
Review effort: Balanced
This branch has not been deployed
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.
ReferenceHandler::prepareArguments() now passes an explicit null through to a nullable parameter. Before, isset() treated it as a missing argument, addressing issue #640
Motivation and Context
prepareArguments() tested isset($arguments[$paramName]), so an argument the client sent as null looked missing. A parameter such as ?string $category = 'books' received 'books' instead of null. The schema allows null and the client sent it, but the handler ran with a different value. The check now also accepts a key that is present with a null value when the parameter allows null.
How Has This Been Tested?
I added a unit test, testHandlePassesAnExplicitNullToANullableParameterWithADefault. It checks that an explicit null gives NULL and that an omitted argument still gives the default 'books'.
Breaking Changes
Types of changes
Additional context