-
Notifications
You must be signed in to change notification settings - Fork 72
Handle Array type query params #41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Handle Array type query params #41
Conversation
WalkthroughThe executeApiTool function in Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor Caller
participant Util as executeApiTool
participant HTTP as HTTP Client
Caller->>Util: call executeApiTool(params)
loop Build query
Util->>Util: for each key/value in params.query
alt value is Array
Note right of Util #E6F7FF: New behavior — filter null/undefined,\nstringify elements, join with ","
Util->>Util: value = value.filter(...).map(String).join(",")
else value is not Array
Util->>Util: value unchanged
end
end
Util->>HTTP: send request with serialized query
HTTP-->>Util: response
Util-->>Caller: result
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Pre-merge checks (3 passed)✅ Passed Checks (3 passed)
Poem
Tip 👮 Agentic pre-merge checks are now available in preview!Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs. 📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
src/utils/security.ts (2)
415-416: Harden serialization: filter nullish, stringify items.Prevents "1,,3" and "[object Object]" leaks when arrays contain null/undefined or non-primitives.
- queryParams[param.name] = Array.isArray(value) ? value.join(',') : value; + queryParams[param.name] = Array.isArray(value) + ? value + .filter((v) => v !== undefined && v !== null) + .map((v) => String(v)) + .join(',') + : value;
415-416: Optional: honor OpenAPI style/explode when available.If
definition.executionParameterscarriesstyle/explode, switch between CSV (explode=false) and repeated params (explode=true), keeping current CSV as default when unspecified.Would you like me to add a small helper serializer that chooses CSV vs repeated params per parameter (without adding deps)?
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/utils/security.ts(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/utils/security.ts (2)
examples/pet-store-sse/src/index.ts (1)
executeApiTool(730-1048)examples/pet-store-streamable-http/src/index.ts (1)
executeApiTool(730-1048)
🔇 Additional comments (1)
src/utils/security.ts (1)
415-416: CSV serialization for array query params — good fix.This directly addresses axios’ default array/bracket serialization and matches the PR intent.
|
The format |
Fixed an issue when extracting tools where if the query param value was an array, it would not get serialized by axios properly.
For example, if I need to specify the fields to return for an api call, I want this:
But it was doing this:
This fix checks if the query param value is an array, and if it is, it joins them into a comma separated list.
Summary by CodeRabbit