Skip to content

fix(api): separate query params from body payload in REST tool POST requests#3720

Merged
jonpspri merged 4 commits intoIBM:mainfrom
Tissandier:improve-post-rest-tools
Apr 13, 2026
Merged

fix(api): separate query params from body payload in REST tool POST requests#3720
jonpspri merged 4 commits intoIBM:mainfrom
Tissandier:improve-post-rest-tools

Conversation

@Tissandier
Copy link
Copy Markdown
Contributor

📝 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

  • Bug fix
  • Feature / Enhancement
  • Documentation
  • Refactor
  • Chore (deps, CI, tooling)
  • Other (describe below)

🧪 Verification

Check Command Status
Lint suite make lint OK
Unit tests make test OK
Coverage ≥ 80% make coverage yes

✅ Checklist

  • Code formatted (make black isort pre-commit)
  • Tests added/updated for changes
  • Documentation updated (if applicable)
  • No secrets or credentials committed

📓 Notes (optional)

Screenshots, design decisions, or additional context.

@Tissandier Tissandier force-pushed the improve-post-rest-tools branch 3 times, most recently from 946c892 to 2b06bdf Compare March 18, 2026 11:08
@crivetimihai crivetimihai added bug Something isn't working SHOULD P2: Important but not vital; high-value items that are not crucial for the immediate release labels Mar 20, 2026
@crivetimihai crivetimihai added this to the Release 1.0.0 milestone Mar 20, 2026
@crivetimihai crivetimihai added the api REST API Related item label Mar 20, 2026
@crivetimihai crivetimihai changed the title improve post for rest tools fix(api): separate query params from body payload in REST tool POST requests Mar 20, 2026
@crivetimihai
Copy link
Copy Markdown
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
marekdano previously approved these changes Mar 27, 2026
Copy link
Copy Markdown
Collaborator

@marekdano marekdano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 placed

After (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:

  1. Add test for GET requests with static query params (e.g., ?version=v2)
  2. Add tests for PUT/PATCH methods with query params (only POST is tested)

LGTM 🚀

@marekdano marekdano added the release-fix Critical bugfix required for the release label Apr 1, 2026
@crivetimihai crivetimihai removed the release-fix Critical bugfix required for the release label Apr 4, 2026
@marekdano marekdano added the release-fix Critical bugfix required for the release label Apr 13, 2026
Emmanuel Tissandier and others added 4 commits April 13, 2026 09:30
Signed-off-by: Emmanuel Tissandier <Emmanuel.Tissandier@fr.ibm.com>
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>
@jonpspri jonpspri force-pushed the improve-post-rest-tools branch from aa545ce to b1768df Compare April 13, 2026 10:26
@jonpspri jonpspri merged commit a93c8e9 into IBM:main Apr 13, 2026
25 checks passed
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api REST API Related item bug Something isn't working release-fix Critical bugfix required for the release SHOULD P2: Important but not vital; high-value items that are not crucial for the immediate release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants