Skip to content

fix(cli): coerce leading numeric flag values (e.g. 1.5s1.5)#54

Open
EfeDurmaz16 wants to merge 2 commits into
vercel-labs:mainfrom
EfeDurmaz16:fix/strict-numeric-flag-parsing
Open

fix(cli): coerce leading numeric flag values (e.g. 1.5s1.5)#54
EfeDurmaz16 wants to merge 2 commits into
vercel-labs:mainfrom
EfeDurmaz16:fix/strict-numeric-flag-parsing

Conversation

@EfeDurmaz16

@EfeDurmaz16 EfeDurmaz16 commented May 15, 2026

Copy link
Copy Markdown

Summary

Addresses @atinux's review: instead of rejecting partial numeric values, coerce the leading number (parseFloat-style) so --temperature 1.5s / --duration 2ms work (→ 1.5 / 2). A leading-number regexp keeps parseFloat from being too permissive, so values with no leading number (e.g. abc) are still rejected.

Behavior

  • 1.5s1.5, 1abc1, .5x0.5
  • abc (no leading number) → still errors
  • negatives / out-of-range still rejected downstream

Tests

  • bun test packages/ai-cli/src/lib/parse.test.ts (20 pass)
  • bun run typecheck
  • bun run format:check

@vercel

vercel Bot commented May 15, 2026

Copy link
Copy Markdown

@EfeDurmaz16 is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

@atinux

atinux commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Hey! Thanks for the PR.

I rather have 1.5s working by being transformed to 1.5 than having an error beeiing thrown here.
Having a custom regexp where parseFloat does a decent job while being not too restrictive is fine IMO

Per review: keep parseFloat leniency so '1.5s' -> 1.5 and '1abc' -> 1, using a
leading-number regexp guard so values with no leading number (e.g. 'abc') are
still rejected. Update tests to assert coercion.
@EfeDurmaz16 EfeDurmaz16 changed the title fix(cli): reject partial numeric flag values fix(cli): coerce leading numeric flag values (e.g. 1.5s1.5) Jul 2, 2026
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.

2 participants