bug: webapp rejects API_RATE_LIMIT_METRICS_BUCKET_SECONDS=15 although the schema says divisors of 60 are valid

Aberta
#4,983 1 comentário 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

Ninguém assumiu esta issue ainda.

  • #4993 de @StackedByAdit — fechado sem integrar

Avaliação

Dificuldade
2/5
Tempo estimado
1-3 horas
Facilidade para iniciantes
20/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Estagnada
Stack de tecnologia
typescript
Domínio
backend

Direção de pesquisa

Comece em apps/webapp/app/env.server.ts:777-785 e confirme que .multipleOf(10) rejeita 15 enquanto o refine permite divisores de 60; o primeiro passo é verificar o PR fechado #4993 para ver por que a correção anterior não foi mergeada. Por concluído entende-se quando o parsing de "15" e "120" tem sucesso, "7" ainda falha e a suite env de Vitest do webapp permanece verde.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

Provide environment information

Not environment-specific: found in the webapp source at main @ c2b7a72180 and reproduced with the webapp's own Vitest suite (macOS arm64, pnpm).

Describe the bug

The webapp refuses to start with API_RATE_LIMIT_METRICS_BUCKET_SECONDS=15, although the schema's own rule says 15 is valid.

In apps/webapp/app/env.server.ts:777-785:

API_RATE_LIMIT_METRICS_BUCKET_SECONDS: z.coerce.number().int().positive()
  .multipleOf(10)
  .refine((seconds) => 60 % seconds === 0 || seconds % 60 === 0, {
    message: "must divide or be a multiple of 60 so buckets align to minute boundaries",
  })

The refine accepts any divisor or multiple of 60, which is the alignment the metrics aggregator needs. .multipleOf(10) runs first, though, and rejects the minute-aligned divisors 15 (and 1–6, 12). Environment parsing fails at startup with a Zod "multiple of 10" error.

Expected: 15 (and 120) parse, 7 is still rejected.

Reproduction repo

N/A (schema test against this repo, below)

To reproduce
  1. Set API_RATE_LIMIT_METRICS_BUCKET_SECONDS=15 and start the webapp. Env validation fails.
  2. Or, as a test: parse "15" with the schema entry above. It fails with Number must be a multiple of 10.
Additional information

A fix is ready on the breken-ai/trigger.dev fork (breken/fix-rate-limit-metrics-bucket-validation):

  • It drops the contradictory .multipleOf(10) and moves the schema into app/utils/apiRateLimitMetricsBucketSecondsSchema.ts, so it can be tested.
  • The regression test asserts 15 and 120 parse and 7 fails. It's red on main and green with the fix.
  • Env + new schema tests: 19 passed. oxfmt, oxlint and webapp typecheck are clean.

I'll open it as a draft PR with fixes #<this> once the account is vouched.

Prepared with AI assistance (Claude) from the breken-ai account.

Linguagem predominante
TypeScript
Estrelas
16.5k
Forks
1.5k
Merge médio
1d 15h
PRs com merge (30d)
17

Preparar o ambiente

Este projeto não oferece contêiner de desenvolvimento, Dockerfile nem guia de contribuição, então a configuração fica por sua conta: comece pelo README e veja nosso guia da primeira contribuição para os passos gerais.

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de triggerdotdev/trigger.dev

Todas as issues de triggerdotdev/trigger.dev

Issues semelhantes

Mais issues de TypeScript

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.