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

Server should respond with invalid params if params are passed to function that doesnt take any #53

Open
isaacgr opened this issue Feb 16, 2020 · 3 comments
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@isaacgr
Copy link
Owner

isaacgr commented Feb 16, 2020

It seems JavaScript is cool with passing params to a funtion that doesnt take any. It'll simply just ignore them and call the function. The server should probably handle throwing the error.

ex.

const test = () => 'I dont take params'
> test('param')
> 'I dont take params'

? this.methods[message.method](params)

@isaacgr isaacgr added the bug Something isn't working label Feb 16, 2020
@isaacgr isaacgr self-assigned this Feb 16, 2020
@isaacgr
Copy link
Owner Author

isaacgr commented Feb 20, 2020

Additionally, since JavaScript uses {} and [] to spread out the parameters, the server wont error if a list argument is passed to an object argument. It will just return undefined for those params. So this should error out as well (I think).

@isaacgr isaacgr added the good first issue Good for newcomers label Jul 16, 2020
@isaacgr
Copy link
Owner Author

isaacgr commented Oct 2, 2020

I wonder if this should just be on the user. The solution here shows that a user could just check the types in the method and throw an error if they are invalid, which would get passed along. In this case the user would throw a TypeError to return an Invalid Params response.

@isaacgr
Copy link
Owner Author

isaacgr commented Oct 2, 2020

Perhaps the library should only throw an error if a user passes params to a function that doesnt accept any, or if an object arg is passed to an array arg and vice versa. Checking the arg types are correct should be the part of the user per the comment above.

@isaacgr isaacgr removed their assignment Oct 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant