Skip to content

Conversation

@GogoVega
Copy link
Contributor

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Proposed changes

If I do a GET request to /plugins/my-plugin-module/my-plugin, the response should be the configuration of the my-plugin plugin and not each configuration contained in my-plugin-module.

Checklist

  • I have read the contribution guidelines
  • For non-bugfix PRs, I have discussed this change on the forum/slack team.
  • I have run npm run test to verify the unit tests pass
  • I have added suitable unit tests to cover the new/changed functionality

@GogoVega
Copy link
Contributor Author

I split the actual route into two:

  • the first to get the module info. This amounts to calling the same route for nodes, as there's no distinction at this level.
  • the second to get the plugin configuration. The Accept header has been adapted to handle application/json and text/plain results.

@GogoVega
Copy link
Contributor Author

Now #5277 is merged, when a user installs a module containing plugins from the Palette Manager, the editor will fetch for the configuration of each plugin.

To do this, the editor receives an array with plugin information and will then make a request per plugin to retrieve its configuration (its HTML content).

$.ajax({
headers: {
"Accept":"text/html",
"Accept-Language": lang
},
cache: false,
url: 'plugins/'+id,
success: function(data) {
appendPluginConfig(data);
}
});

The problem is that the request returns the contents of all plugins in that module instead of the one requested. I mean the request contains the plugin ID but the function is called with the module name.

getConfig: function(req, res) {
let opts = {
user: req.user,
module: req.params[0],
req: apiUtils.getRequestLogObject(req)
}

function generateModulePluginConfig(module) {
let result = '';
const plugins = module.plugins
for (let plugin in plugins) {
if (plugins.hasOwnProperty(plugin)) {
let config = plugins[plugin];
if (config.enabled && !config.err && config.config) {
result += "\n<!-- --- [red-plugin:"+config.id+"] --- -->\n";
result += config.config;
}
}
}
return result;
}

As a result, if the array contains two plugins, the onadd method will be called twice for each plugin.

To solve this problem I propose to get closer to the functioning of nodes; getConfig will return the contents of the specified plugin as getSet does for nodes.

@knolleary knolleary merged commit 8cf1e73 into node-red:master Dec 3, 2025
5 checks passed
@GogoVega GogoVega deleted the fix-plugins-getConfig branch December 3, 2025 18:50
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.

2 participants