Skip to content

fix(tasks): validate task options at registration - #307

Open
mcollina wants to merge 2 commits into
mainfrom
fix/302-validate-task-options
Open

mcollina wants to merge 2 commits into
mainfrom
fix/302-validate-task-options

Conversation

@mcollina

@mcollina mcollina commented Oct 15, 2026 •

Copy link
Copy Markdown
Member

Only sessionTtlMs, allowedOrigins and taskMaxRetainedPerPrincipal were validated at registration. taskLeaseMs, taskDefaultTtlMs and taskMaxTtlMs were used as given, so taskLeaseMs: 0 failed every task within milliseconds and taskDefaultTtlMs: NaN or -5 made every task expire at once. These errors only showed up at runtime.

Changes:

  • taskLeaseMs, taskDefaultTtlMs and taskMaxTtlMs must be positive safe integers. Otherwise registration throws a TypeError naming the option. This check runs whether or not enableTasks is set, and before any Redis connection is opened. undefined still means "use the default".
  • A taskDefaultTtlMs above taskMaxTtlMs is still accepted and capped, as before, so working configurations keep loading. Rejecting it is a separate, breaking change.
  • README documents the constraints.
  • New test/task-options-validation.test.ts.

The values now rejected (zero, negative, NaN, Infinity) already broke tasks at runtime. Non-numbers such as numeric strings were already type errors under MCPPluginOptions.

The issue also lists taskShutdownTimeoutMs, taskMaxConcurrent, taskMaxPerPrincipal and taskStoreMaxTasks. None of these exist in MCPPluginOptions. The per-principal cap is taskMaxRetainedPerPrincipal, which was already validated and now has tests. The in-memory store's 1000-task cap cannot be configured.

Fixes #302

🤖 Generated with Claude Code

https://claude.ai/code/session_01UF4S3w7iA83V9DVsasLJzM

mcollina and others added 2 commits October 15, 2026 13:16
Only sessionTtlMs, allowedOrigins and taskMaxRetainedPerPrincipal were
checked at registration; taskLeaseMs, taskDefaultTtlMs and taskMaxTtlMs
were used as given. A zero lease lapsed immediately and failed every
task, and a NaN or negative ttl (e.g. Number(process.env.X) when unset)
made every task expire at once, all surfacing only at runtime.

Registration now requires each of them to be a positive safe integer and
throws a TypeError naming the option otherwise. An explicit
taskDefaultTtlMs above the resolved taskMaxTtlMs (default 1 hour) is
also rejected, since it would be silently capped. Validation runs before
any Redis connection is opened.

Fixes #302

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UF4S3w7iA83V9DVsasLJzM
Throwing when the default ttl exceeds the ceiling rejects configurations
that work today (the default is silently capped), which would make this a
breaking change. Keep the existing capping here and only reject values
that already broke every task; enforcing the ceiling is left to a
separate change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UF4S3w7iA83V9DVsasLJzM

This branch has not been deployed

No deployments
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.

Task options are not validated at registration: taskLeaseMs: 0 or taskDefaultTtlMs: NaN break every task

1 participant