Skip to content

Lack of typesafety #32

@goleary

Description

@goleary

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions