sdk-python icon indicating copy to clipboard operation
sdk-python copied to clipboard

[BUG] TypeScript Web Fetch accepts non-finite size limits

Open 97Three opened this issue 2 months ago • 3 comments

Checks

  • [x] I have checked the documentation and this is not expected behavior
  • [x] I have searched existing issues and pull requests and found no duplicate

SDK Language

TypeScript

Strands Version

Current main at 08ed4cfd3eb42ae9f668595e675d5f196eee7e44

Steps to Reproduce

import { makeWebFetch } from '@strands-agents/sdk/vended-tools'

for (const value of [Number.NaN, Number.POSITIVE_INFINITY]) {
  makeWebFetch({ mode: 'markdown', maxBytes: value })
  makeWebFetch({ mode: 'markdown', maxContentChars: value })
}

All four calls complete without throwing.

Expected Behavior

maxBytes and maxContentChars should reject non-finite values. Both options represent positive resource limits, so accepted values should be finite and greater than zero.

Actual Behavior

NaN and Infinity pass validation. With NaN, comparisons such as total > maxBytes and content.length > maxContentChars are always false. Infinity likewise disables the configured cap.

Additional Context

The factory currently checks only value <= 0. JavaScript comparisons with NaN are false, and positive infinity is greater than zero.

Open PR #4298 changes how Web Fetch performs requests but retains the same validation and does not address this issue.

Possible Solution

Add Number.isFinite() to the existing positive-value validation for both options, with focused TypeScript regression tests for NaN and Infinity. No Python SDK changes are needed for this issue.

97Three avatar Sep 14 '26 08:09 97Three

I'd be happy to work on this as a focused TypeScript fix. I have a minimal patch locally that adds Number.isFinite() to the existing validation, with regression coverage for NaN and positive/negative Infinity. I'll wait for maintainer confirmation before opening a PR.

97Three avatar Sep 14 '26 08:09 97Three

Hi @97Three, i'm interested in picking this up, are you still planning to send the PR? Happy to take it if not.

SajjadAliZaidi avatar Sep 29 '26 11:09 SajjadAliZaidi

I'll take this. Opening a PR that rejects non-finite maxBytes and maxContentChars (NaN and Infinity) and adds tests.

Li-john1021 avatar Sep 30 '26 03:09 Li-john1021