You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bug: webapp rejects API_RATE_LIMIT_METRICS_BUCKET_SECONDS=15 although the schema says divisors of 60 are valid #4983
Not environment-specific: found in the webapp source at main @ c2b7a72 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
Set API_RATE_LIMIT_METRICS_BUCKET_SECONDS=15 and start the webapp. Env validation fails.
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.
Activity