Skip to content

fix: correct firmware API base path and destructure parameter objects#3

Open
chr2sn0 wants to merge 1 commit into
Pixelworlds:masterfrom
chr2sn0:fix/firmware-api-paths
Open

fix: correct firmware API base path and destructure parameter objects#3
chr2sn0 wants to merge 1 commit into
Pixelworlds:masterfrom
chr2sn0:fix/firmware-api-paths

Conversation

@chr2sn0

@chr2sn0 chr2sn0 commented Jun 22, 2026

Copy link
Copy Markdown

This PR addresses two critical bugs when interacting with the OPNsense firmware API module:

1. Correct base path mapping for the Firmware module

  • Problem: The firmware endpoints in OPNsense actually reside under the core module path: /api/core/firmware. The generators mapped it to /api/firmware (using the subfolder name /typescript/core/firmware), which resulted in 404 Not Found errors for all firmware actions (install, update, query, etc.).
  • Fix: Adjusted generators/generate-core-modules.js and generators/generate-sdk.js to map firmware to /api/core/firmware.

2. Object parameter support (destructuring) for SDK methods

  • Problem: When calling firmware endpoints via MCP tool dispatching (e.g. firmwareInstall({pkgName: "os-crowdsec"})), parameters were being serialized incorrectly as [object Object] in the URL path.
  • Fix: Added overloaded method signatures in typescript/core/firmware.ts to accept parameter objects and safely destructure variables (such as pkgName, version, and clear) into URL segments.

Technical Details

  • generators/generate-core-modules.js:
    Maps firmware's basePath to /api/core/firmware.
  • generators/generate-sdk.js:
    Aligns regexes and transforms class constructor types dynamically to map paths correctly. Also corrects the Rollup bundle outputs in package.json to matching .js/.cjs extensions.
  • typescript/core/firmware.ts:
    Declares helper methods and object signatures for single-object parameters.
  • src/core/firmware.ts:
    Regenerated SDK module.

…irmware

The firmware controller in OPNsense lives under the 'core' module,
making /api/core/firmware the correct base path. The generators were
incorrectly deriving the path as /api/firmware (using the module name
literally), which resulted in 404 errors on all firmware API calls.

Changes:
- generators/generate-core-modules.js: Map firmware module basePath
  to /api/core/firmware instead of /api/firmware
- generators/generate-sdk.js: Apply same basePath mapping during SDK
  transformation, fix package.json export filenames to match Rollup
  output (.cjs/.js instead of .js/.esm.js)
- typescript/core/firmware.ts: Add object-parameter overloads for
  methods with path parameters (pkgName, version, clear) to support
  single-object invocation from MCP tool dispatch
- src/core/firmware.ts: Regenerated with correct paths and overloads
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant