Prerequisites
Toolbox version
latest (main branch)
Environment
- OS type and version: Any (affects all platforms)
- How are you running Toolbox: Local Docker image
Client
- Client: Any HTTP tool (see example below)
- Version: N/A
- Example: Minimal YAML config and curl example below
Expected Behavior
When invoking an HTTP tool with optional query parameters not specified (or set to null/nil), the generated HTTP request URL should omit those parameters. For example, if both page and pageSize are optional and not provided, the URL should be:
https://api.example.com/endpoint
This matches REST API standards, avoids sending empty query values, and prevents API errors.
Current Behavior
The HTTP tool implementation in internal/tools/http/http.go currently converts nil values for optional query parameters to empty strings and always includes them in the request URL (e.g., ?page=&pageSize=). Strict APIs reject these requests with HTTP 400 Bad Request errors, even though the intention is to omit the optional parameters entirely.
Minimal Example
tools:
my-http-tool:
kind: http
source: my-http-source
method: GET
path: /data
queryParams:
- name: page
type: integer
required: false
- name: pageSize
type: integer
required: false
Invoke with:
curl -X POST http://localhost:5000/api/tool/my-http-tool/invoke \
-H "Content-Type: application/json" \
-d '{}'
Resulting URL (buggy):
https://api.example.com/data?page=&pageSize=
API returns: HTTP 400 Bad Request
Steps to reproduce?
- Create an HTTP tool with optional query parameters as above
- Invoke the tool with
{} (no parameters)
- Observe the generated request URL and HTTP 400 response from the upstream API
Additional Details
- Root Cause:
In internal/tools/http/http.go, the getURL() function (lines 210-229) adds ALL query parameters, converting nil to "" (empty string) and always adding them to the query string.
for _, p := range queryParams {
v := paramsMap[p.GetName()]
if v == nil {
v = ""
}
query.Add(p.GetName(), fmt.Sprintf("%v", v))
}
- Impact:
- APIs that validate query parameter values return HTTP 400 errors
- Affects any HTTP tool with optional query parameters
- Breaks integrations with strict APIs (e.g., DNB Statistics API)
- Violates REST API conventions
- Proposed Solution:
Update the loop in getURL() to skip optional query parameters when their value is nil, only adding them if required or provided.
for _, p := range queryParams {
v, ok := paramsMap[p.GetName()]
if !ok {
if p.GetRequired() {
return "", fmt.Errorf("required query parameter %q is missing", p.GetName())
}
continue
}
if v == nil {
if p.GetRequired() {
v = ""
} else {
continue
}
}
query.Add(p.GetName(), fmt.Sprintf("%v", v))
}
- Testing:
- Test with all-optional parameters omitted (expect HTTP 200 OK from API)
- Test with some provided and some omitted (no empty query values)
- Test required parameters (should remain enforced)
- Docs:
- No documentation change needed; current docs already state optional params can be omitted
References:
Please prioritize this as it breaks compatibility with many APIs and is a standards violation.
Prerequisites
Toolbox version
latest (main branch)
Environment
Client
Expected Behavior
When invoking an HTTP tool with optional query parameters not specified (or set to
null/nil), the generated HTTP request URL should omit those parameters. For example, if bothpageandpageSizeare optional and not provided, the URL should be:This matches REST API standards, avoids sending empty query values, and prevents API errors.
Current Behavior
The HTTP tool implementation in
internal/tools/http/http.gocurrently convertsnilvalues for optional query parameters to empty strings and always includes them in the request URL (e.g.,?page=&pageSize=). Strict APIs reject these requests with HTTP 400 Bad Request errors, even though the intention is to omit the optional parameters entirely.Minimal Example
Invoke with:
Resulting URL (buggy):
API returns:
HTTP 400 Bad RequestSteps to reproduce?
{}(no parameters)Additional Details
In
internal/tools/http/http.go, thegetURL()function (lines 210-229) adds ALL query parameters, convertingnilto""(empty string) and always adding them to the query string.Update the loop in
getURL()to skip optional query parameters when their value isnil, only adding them if required or provided.References:
Please prioritize this as it breaks compatibility with many APIs and is a standards violation.