fix(api): separate query params from body payload in REST tool POST requests#3720
Merged
fix(api): separate query params from body payload in REST tool POST requests#3720
Conversation
946c892 to
2b06bdf
Compare
Member
|
Thanks @Tissandier. Good fix — correctly separates query parameters from the JSON body for POST/PUT/PATCH/DELETE REST tool invocations. The test case covering path params, templated query params, static query params, and body params is thorough. LGTM. |
marekdano
previously approved these changes
Mar 27, 2026
Collaborator
There was a problem hiding this comment.
Thanks for the contribution, @Tissandier!!!
Summary
This PR successfully fixes a bug where REST API tools couldn't properly handle POST requests with query parameters. The fix correctly separates query parameters from the JSON body payload.
✅ Test Coverage
New Test: test_invoke_tool_rest_post_with_path_query_and_body_params
✅ test_invoke_tool_rest_parameter_substitution - PASSED
✅ test_invoke_tool_rest_post_with_path_query_and_body_params - PASSED
✅ Database performance tests - 57 passed
🎯 What This Fixes
Before (Broken):
# POST with query params failed - all params went to body
POST /api/users/456/posts
Body: {"user_id": 456, "api_key": "secret123", "title": "New Post", "content": "Hello"}
# Query params were lost or incorrectly placedAfter (Fixed):
# POST with query params works correctly
POST /api/users/456/posts?api_key=secret123&version=v2
Body: {"title": "New Post", "content": "Hello"}
# Path params substituted, query params in URL, body params in JSON🔒 Security & Performance
- ✅ No security concerns introduced
- ✅ No performance regressions
- ✅ Proper parameter sanitization maintained
- ✅ HTTP client timeout handling unchanged
💡 Optional Future Enhancements (Non-blocking)
The following could be addressed in follow-up work if desired:
- Add test for GET requests with static query params (e.g.,
?version=v2) - Add tests for PUT/PATCH methods with query params (only POST is tested)
LGTM 🚀
Signed-off-by: Emmanuel Tissandier <Emmanuel.Tissandier@fr.ibm.com>
Signed-off-by: Emmanuel Tissandier <Emmanuel.Tissandier@fr.ibm.com>
…T tools Move query param merging into method-specific branches (GET vs non-GET) while keeping the same runtime behavior as main. Add tests for GET with static query params, PUT with query params, and POST with combined path/query/body params. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Jonathan Springer <jps@s390x.com>
aa545ce to
b1768df
Compare
claudia-gray
pushed a commit
that referenced
this pull request
Apr 13, 2026
…equests (#3720) * improve post for rest tools Signed-off-by: Emmanuel Tissandier <Emmanuel.Tissandier@fr.ibm.com> * test on new may to handle query parameters for POST Signed-off-by: Emmanuel Tissandier <Emmanuel.Tissandier@fr.ibm.com> * clean up Signed-off-by: Emmanuel Tissandier <Emmanuel.Tissandier@fr.ibm.com> * fix(tools): preserve backward-compatible query param handling for REST tools Move query param merging into method-specific branches (GET vs non-GET) while keeping the same runtime behavior as main. Add tests for GET with static query params, PUT with query params, and POST with combined path/query/body params. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Jonathan Springer <jps@s390x.com> --------- Signed-off-by: Emmanuel Tissandier <Emmanuel.Tissandier@fr.ibm.com> Signed-off-by: Jonathan Springer <jps@s390x.com> Co-authored-by: Emmanuel Tissandier <Emmanuel.Tissandier@fr.ibm.com> Co-authored-by: Jonathan Springer <jps@s390x.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
📝 Summary
This PR changes the way the tools that are created with a REST api are using the tool payload. Before the change it was not possible to have a tool doing a POST on a REST API with query parameters
🏷️ Type of Change
🧪 Verification
make lintmake testmake coverage✅ Checklist
make black isort pre-commit)📓 Notes (optional)
Screenshots, design decisions, or additional context.