-
-
Notifications
You must be signed in to change notification settings - Fork 821
Open
Description
Provide environment information
System:
OS: macOS 14.5
CPU: (10) arm64 Apple M1 Max
Memory: 2.09 GB / 32.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 20.12.2 - ~/.nvm/versions/node/v20.12.2/bin/node
Yarn: 1.22.19 - ~/.yarn/bin/yarn
npm: 10.5.0 - ~/.nvm/versions/node/v20.12.2/bin/npm
pnpm: 9.14.2 - ~/Library/pnpm/pnpm
bun: 1.0.35 - ~/.bun/bin/bun
Describe the bug
I would expect the number to be accepted, validation to succeed and the resulting payload object to contain a bignumber.
Instead, despite clearly giving a number, we get a zod validation error stating that a (bignumber) object was verified instead of a number.
TaskPayloadParsedError: Parsing payload with schema failed: [
{
"expected": "number",
"code": "invalid_type",
"path": [
"foo"
],
"message": "Invalid input: expected number, received object"
}
]
Reproduction repo
https://github.com/RickVM/trigger-dev-transform-bug-repro
To reproduce
Simply run debugTask.
This is all the code:
import { logger, schemaTask } from "@trigger.dev/sdk";
import { bignumber } from "mathjs";
import { z } from "zod";
export const subTask = schemaTask({
id: "debug-sub-task",
schema: z.object({
foo: z.number().transform((val) => bignumber(val)),
}),
run: async (_) => {
// throws err before.
logger.info("Sub task started");
return {
message: "Sub task completed",
};
},
});
export const mainTask = schemaTask({
id: "debug-task",
schema: z.object({
someNumber: z.number().default(1),
}),
run: async (payload) => {
const result = await subTask.triggerAndWait({ foo: payload.someNumber });
logger.info("Sub task result", { result });
return {
message: "Main task completed",
};
},
});
export default mainTask;
Additional information
No response
Metadata
Metadata
Assignees
Labels
No labels