fix: resolve positional URL parameter passing in callModularTool - #10
Open
papajade55-debug wants to merge 1 commit into
Open
papajade55-debug wants to merge 1 commit into
papajade55-debug wants to merge 1 commit into
Conversation
The callModularTool method was passing all parameters as a single object
to client SDK methods, but many methods expect positional URL parameters
(e.g. pingStart(jobid, data, config) → POST /api/diagnostics/ping/start/${jobid}).
This caused all methods with URL-embedded parameters to fail silently:
- pingStart, pingStop, pingRemove
- packetCaptureStart, packetCaptureStop
- firewallDelState, firewallPfStatistics
- All *DelItem, *GetItem, *SetItem methods across all modules
- All *Toggle* methods
- And ~200+ other methods with URL parameters
The fix detects positional URL methods by checking if callParams contains
known URL parameter names (uuid, jobid, stateid, etc.) AND the method
expects more than 1 argument. When detected, URL params are extracted
positionally and remaining params are passed as the data object.
Fixes Pixelworlds#1
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.
Problem
The
callModularToolmethod passes all parameters as a single object to client SDK methods:But the client SDK (
@richard-stovall/opnsense-typescript-client) uses positional URL parameters for methods that embed values in the URL path. For example:When
callModularToolcallsmethod.call(moduleObj, { uuid: "abc" }), the SDK receivesjobid = { uuid: "abc" }(an object instead of a string), producing the URL/api/diagnostics/ping/start/[object Object]which fails.Impact
~200+ methods across all modules are affected, including:
pingStart,pingStop,pingRemove— diagnostics pingpacketCaptureStart,packetCaptureStop— packet capturefirewallDelState,firewallPfStatistics— firewall diagnostics*DelItem,*GetItem,*SetItemmethods — CRUD operations*Toggle*methods — enable/disable*DelRule,*GetRule,*SetRule— NAT/filter rule management*DelServer,*GetServer,*SetServer— server managementFix
The fix detects positional URL methods at runtime by checking two conditions:
method.length > 1)uuid,jobid,stateid, etc.)When both conditions are met, URL params are extracted positionally from the params object, and remaining params are passed as the data/body object.
Testing
All 13 test cases pass:
Files changed
src/build.ts— template source for the single-file serverindex.js— compiled server (patched for immediate use)