Skip to content

Fix Prompt#validate_arguments! crash when arguments are nil#246

Open
koic wants to merge 1 commit intomodelcontextprotocol:mainfrom
koic:fix_prompt_nil_arguments
Open

Fix Prompt#validate_arguments! crash when arguments are nil#246
koic wants to merge 1 commit intomodelcontextprotocol:mainfrom
koic:fix_prompt_nil_arguments

Conversation

@koic
Copy link
Member

@koic koic commented Feb 27, 2026

Motivation and Context

Prompt#validate_arguments! called required_args which does arguments_value.filter_map, crashing with NoMethodError when arguments_value is nil (the default for prompts without declared arguments). Additionally, passing nil as args caused a crash on args.keys.

Fix by defaulting arguments_value to [] and guarding against nil args.

How Has This Been Tested?

Added a repro test to verify the fix and prevent regression.

Breaking Changes

None.

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

`Prompt#validate_arguments!` called `required_args` which does `arguments_value.filter_map`,
crashing with `NoMethodError` when `arguments_value` is `nil` (the default for prompts without
declared arguments). Additionally, passing `nil` as args caused a crash on `args.keys`.

Fix by defaulting `arguments_value` to `[]` and guarding against `nil` args.
@koic koic force-pushed the fix_prompt_nil_arguments branch from 7cd355d to 3d84eab Compare February 28, 2026 08:52
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.

1 participant