Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Action params list returned by $node.list garbled for arrays #1305

Open
tstiemerling opened this issue Oct 16, 2024 · 0 comments
Open

Action params list returned by $node.list garbled for arrays #1305

tstiemerling opened this issue Oct 16, 2024 · 0 comments

Comments

@tstiemerling
Copy link

🛑 Do you want to ask a question ?

Please head to the Discord chat

Prerequisites

Please answer the following questions for yourself before submitting an issue.

  • [x ] I am running the latest version
  • [x ] I checked the documentation and found no answer
  • [x ] I checked to make sure that this issue has not already been filed
  • [x ] I'm reporting the issue to the correct repository

Current Behavior

Defining an action as follows:

actions: {
create: {
rest: "POST /",
permission: "create",
params: {
$$strict: "remove",
name: { type: "string" },
description: { type: "string", optional: true },
users: { type: "array", items: "string", optional: true },
},
handler: this.create,
},

results in $node.list returning the following:

{"rest":"POST /",
"permission":"create",
"params":{
"$$strict":"remove",
"name":{"type":"string","convert":true},
"description":{"type":"string","optional":true,"convert":true},
"users":{"type":"array","items":{"0":"s","1":"t","2":"r","3":"i","4":"n","5":"g","type":"any","optional":true},"optional":true}
},
"rawName":"create",
"name":"usergroup.create"}

As a result, the moleculer REST API page does not function for array params.

Expected Behavior

Would expect correct conversion of array params.

Failure Information

Cannot submit array params using moleculer REST API page (may have other side effects as well?)

Steps to Reproduce

The above code is from one of our services - we dont have a sample example at this time.

Reproduce code snippet

See above.

Context

Please provide any relevant information about your setup. This is important in case the issue is not reproducible except for under certain conditions.

  • Moleculer version: 0.14.33
  • NodeJS version: 22.8.0
  • Operating System: Windows 11

Failure Logs

{
  "name": "ValidationError",
  "message": "Parameters validation error!",
  "code": 422,
  "type": "VALIDATION_ERROR",
  "data": [
    {
      "type": "array",
      "message": "The 'users' field must be an array.",
      "field": "users",
      "actual": "[\"VFv222B44eRuTzgG\"]",
      "nodeID": "ci0600000001939-29180",
      "action": "usergroup.create"
    }
  ]
}
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

No branches or pull requests

1 participant