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

Lack of typesafety #32

Open
goleary opened this issue Jul 1, 2024 · 0 comments
Open

Lack of typesafety #32

goleary opened this issue Jul 1, 2024 · 0 comments

Comments

@goleary
Copy link

goleary commented Jul 1, 2024

We have a Retool RPC endpoint that looks like this:

rpc.register({
  name: "function",
  arguments: {
    projectId: { type: "string", description: "A string input", required: false },
  },
  implementation: async (args, context) => {
    console.log('args.projectId', args.projectId);
  },
});

The problem is that Retool seems to be allowing passing of non string values via RPC. You can see how we are passing a variable here:
image
But this variable is nullable
image

Nothing in Retool indicates an issue and we can call the function with this value.

Also the retool rpc package doesn't seem to parse the values coming in, so now our types are wrong:
image
Which has resulted in some nasty runtime errors, partially defeating the purpose of using something like Retool RPC + Typescript.

To avoid any more issues of this nature I'm considering using zod to parse the arguments that come from Retool RPC, but this is cumbersome because it will require defining the types multiple times, once for retool and once for zod.

Doing some sort of parsing or validation either in the rpc package or in the retool dashboard would make this feature much safer to use.

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