Skip to content

bug: [v4] retrying after schema fails #1955

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

Open
cachho opened this issue Apr 19, 2025 · 1 comment
Open

bug: [v4] retrying after schema fails #1955

cachho opened this issue Apr 19, 2025 · 1 comment

Comments

@cachho
Copy link

cachho commented Apr 19, 2025

Provide environment information

System:
OS: Linux 5.15 Ubuntu 20.04.6 LTS (Focal Fossa)
CPU: (12) x64 AMD Ryzen 5 5600X 6-Core Processor
Memory: 4.84 GB / 15.59 GB
Container: Yes
Shell: 3.7.1 - /usr/bin/fish
Binaries:
Node: 18.20.8 - ~/.local/share/nvm/v18.20.8/bin/node
npm: 10.8.2 - ~/.local/share/nvm/v18.20.8/bin/npm
pnpm: 8.6.3 - ~/.local/share/pnpm/pnpm

Describe the bug

According to the docs, when the schema fails it should not retry, but it does.

This is unnecessarily increasing the run time and cost.

Reproduction repo

added screenshot below.

To reproduce

convert-or-decrypt-link.ts

import { AbortTaskRunError, logger, schemaTask, tags } from '@trigger.dev/sdk';
import type { CnLinkSerial } from 'cn-links';
import { CnLink } from 'cn-links';
import { z } from 'zod';

import { decryptLink } from './decrypt-link';

export const convertOrDecryptLink = schemaTask({
  id: 'convert-or-decrypt-link',
  schema: z.object({
    link: z.string().url(),
  }),
  // Set an optional maxDuration to prevent tasks from running indefinitely
  maxDuration: 30,
  run: async (payload: { link: string }): Promise<CnLinkSerial> => {
    const url = new URL(payload.link);
    // do something. It triggers another task here and/or adds tags, so I know for sure that it fails during the initial schema.
  },
});

Tested in production and local development.

Additional information

Image

@cachho
Copy link
Author

cachho commented Apr 20, 2025

There is an error message for an invalid schema (taken from elsewhere)

Image

So it looks like this may have been caused by the child task, which has stricter schema rules and uses refine.

export const decryptLink = schemaTask({
  id: 'decrypt-link',
  schema: z.object({
    link: z
      .string()
      .url()
      .refine((val) => HostnameSchema.safeParse(new URL(val).hostname).success),
  }),

This would match the error, it's 100% in the decrypt-link function and not convert-or-decrypt-link, because the URL schema is actually not illegal, HostnameSchema is causing it to fail.

But then it should still fail in the child task, not the parent task, and it should still not retry. The screenshot above shows no indication the the child task was even called, so I think this might be a problem where a child task is called with a schema.

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