Skip to content

fix: safe parse of MAX_SANDBOX_DURATION and enforce maxDuration bounds - #3

Open
feafel wants to merge 1 commit into
RitualChain:mainfrom
feafel:fix/safe-env-parse
Open

feafel wants to merge 1 commit into
RitualChain:mainfrom
feafel:fix/safe-env-parse

Conversation

@feafel

@feafel feafel commented Oct 12, 2026

Copy link
Copy Markdown

Problem
parseInt(process.env.MAX_SANDBOX_DURATION || "300",10) returns NaN when env var is set to empty string, causing DB default and Zod default to become NaN. This propagates to sandbox timeout and task execution.

Fix

  • Add parseIntEnv helper that validates finite positive int, falls back to 300.
  • Use helper for both Drizzle schema default and Zod schema default.
  • Enforce .min(1).max(480) on insertTaskSchema.maxDuration to cap cost.

Impact
Prevents NaN defaults and unbounded sandbox runtime.

Add parseIntEnv helper to avoid NaN defaults when env var is empty/invalid.
Enforce .min(1).max(480) on insertTaskSchema.maxDuration.
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

Successfully merging this pull request may close these issues.

1 participant