fix: allow empty elicitation form data when all fields are optional
Summary
When all of the fields of the schema for an elicitation are optional, it should be possible to hit the Submit button (sending "accept") without filling in any of the fields. Prior to this change, this would fail in the UI with:
Validation Error: data should be object
Previously, in this case, generateDefaultValue() would produce undefined as the default value, but as of this change, it produces {} instead. The undefined would fail the check here:
https://github.com/modelcontextprotocol/inspector/blob/dff91a869683a309c69aaf2868e7982f76cc22f4/client/src/components/ElicitationRequest.tsx#L82-L90
Now it passes.
Note: Inspector V2 is under development to address architectural and UX improvements. See CONTRIBUTING.md for information about V2 development.
Type of Change
- [x] Bug fix (non-breaking change that fixes an issue)
- [ ] New feature (non-breaking change that adds functionality)
- [ ] Documentation update
- [ ] Refactoring (no functional changes)
- [ ] Test updates
- [ ] Build/CI improvements
Changes Made
Related Issues
Testing
- [x] Tested in UI mode
- [ ] Tested in CLI mode
- [x] Tested with STDIO transport
- [ ] Tested with SSE transport
- [ ] Tested with Streamable HTTP transport
- [ ] Added/updated automated tests
- [x] Manual testing performed
Test Results and/or Instructions
Screenshots are encouraged to share your testing results for this change.
Checklist
- [x] Code follows the style guidelines (ran
npm run prettier-fix) - [x] Self-review completed
- [x] Code is commented where necessary
- [x] Documentation updated (README, comments, etc.)
Breaking Changes
Additional Context
I don't understand what happened: why did an action in an unrelated repo close this PR?
@olaservo added proposed tests
@cliffhall would you be willing to take a look?
Thanks so much @olaservo!