fix(cloud-runpod): reject non-decimal sizing options#809
Conversation
There was a problem hiding this comment.
Pull request overview
This PR tightens input validation in the RunPod cloud adapter to reject non-plain-decimal sizing strings (e.g., scientific notation and hex) before any provisioning API call, and adds focused unit coverage to prevent regressions.
Changes:
- Replace
Number(...)parsing for sizing fields with a newplainDecimalNumber(...)validator. - Reject non-decimal numeric strings (e.g.,
1e2,0x10) for volume/disk/CPU/memory sizing. - Add a RunPod adapter test ensuring invalid sizing values fail before
fetchis invoked.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/cloud/runpod/src/index.ts | Introduces plainDecimalNumber and routes sizing parsing through it to block scientific/hex string inputs. |
| packages/cloud/runpod/src/index.test.ts | Adds a regression test to ensure invalid sizing strings are rejected before provisioning triggers network calls. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| function plainDecimalNumber(value: Numberish, label: string): number { | ||
| if (typeof value === 'number') return value; | ||
| const text = value.trim(); | ||
| if (!/^(?:0|[1-9]\d*|0?\.\d+|[1-9]\d*\.\d+)$/.test(text)) { | ||
| throw new Error(`RunPod ${label} must be a plain decimal number`); | ||
| } | ||
| return Number(text); | ||
| } |
|
🤖 Auto-rebase: The branch was rebased successfully locally but could not be pushed to the fork. Please enable 'Allow edits from maintainers' in the PR settings, or rebase manually: |
3 similar comments
|
🤖 Auto-rebase: The branch was rebased successfully locally but could not be pushed to the fork. Please enable 'Allow edits from maintainers' in the PR settings, or rebase manually: |
|
🤖 Auto-rebase: The branch was rebased successfully locally but could not be pushed to the fork. Please enable 'Allow edits from maintainers' in the PR settings, or rebase manually: |
|
🤖 Auto-rebase: The branch was rebased successfully locally but could not be pushed to the fork. Please enable 'Allow edits from maintainers' in the PR settings, or rebase manually: |
Summary
Verification
Note: running through pnpm in this workspace currently triggers an unrelated lockfile policy failure for @profullstack/autoblog@0.4.0 missing tarball integrity, so I ran the local Vitest and TypeScript binaries directly.