Fix callModularTool to pass positional args to API methods#5
Open
issmirnov wants to merge 1 commit into
Open
Conversation
The callModularTool function was merging all params into a single object and passing it as the first argument to API client methods. This broke methods like settingsSetHost(uuid, data, config) because the URL became `/api/dnsmasq/settings/set_host/[object Object]` and the POST body was undefined. The fix introspects each method's parameter names via Function.toString() and passes arguments positionally: named params like `uuid` and `enabled` are extracted and passed as leading positional args, with remaining data passed as the `data` argument. This correctly handles all API method signatures: (config), (data, config), (uuid, data, config), and (uuid, enabled, data, config). 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
callModularToolmerges all params into a single object and passes it as the sole argument to API client methods. Methods likesettingsSetHost(uuid, data, config)expectuuidas the first positional arg anddataas the second. The current code causes the URL to become/api/dnsmasq/settings/set_host/[object Object]and the POST body to beundefined.Function.toString()and pass arguments positionally. Named params likeuuidandenabledare extracted from the merged params object and passed as leading positional args, with remaining data passed as thedataargument.(config),(data, config),(uuid, data, config), and(uuid, enabled, data, config).Details
The previous code:
The fix parses parameter names from the method source and builds positional args:
Test plan
settingsSetHostwith uuid correctly produces URL/api/dnsmasq/settings/set_host/<uuid>with POST bodysettingsToggleZonewith uuid and enabled correctly produces URL with both path paramssettingsGet(no params) still workssettingsAddHost(data only) still works🤖 Generated with Claude Code