stablyai/orca · error · RuntimeClientError
invalid_argument
invalid_argument
Error message
--scale must be a positive number
What it means
Thrown by the `browser-env viewport` handler when --scale is provided but Number(scale) is not finite or is <= 0. deviceScaleFactor must be a positive number, so zero, negatives, NaN, and Infinity are all rejected before the browser.viewport RPC.
Source
Thrown at src/cli/handlers/browser-env.ts:22
import {
getOptionalStringFlag,
getRequiredFiniteNumber,
getRequiredPositiveNumber,
getRequiredStringFlag
} from '../flags'
import { RuntimeClientError } from '../runtime-client'
import { getBrowserCommandTarget } from '../selectors'
export const BROWSER_ENV_HANDLERS: Record<string, CommandHandler> = {
viewport: async ({ flags, client, cwd, json }) => {
const width = getRequiredPositiveNumber(flags, 'width')
const height = getRequiredPositiveNumber(flags, 'height')
const params: Record<string, unknown> = { width, height }
const scale = getOptionalStringFlag(flags, 'scale')
if (scale) {
const n = Number(scale)
if (!Number.isFinite(n) || n <= 0) {
throw new RuntimeClientError('invalid_argument', '--scale must be a positive number')
}
params.deviceScaleFactor = n
}
if (flags.has('mobile')) {
params.mobile = true
}
Object.assign(params, await getBrowserCommandTarget(flags, cwd, client))
const result = await client.call<BrowserViewportResult>('browser.viewport', params)
printResult(
result,
json,
(v) => `Viewport set to ${v.width}×${v.height}${v.mobile ? ' (mobile)' : ''}`
)
},
geolocation: async ({ flags, client, cwd, json }) => {
const latitude = getRequiredFiniteNumber(flags, 'latitude')
const longitude = getRequiredFiniteNumber(flags, 'longitude')
const params: Record<string, unknown> = { latitude, longitude }View on GitHub (pinned to 1136503c6a)
Solutions
- Pass a positive finite scale factor such as `--scale 2` for retina.
- Omit --scale entirely to leave deviceScaleFactor unset (the flag is optional).
- Verify the value is not coming from an empty/unset environment variable.
Example fix
// before orca browser-env viewport --width 1280 --height 720 --scale 0 // after orca browser-env viewport --width 1280 --height 720 --scale 2
Defensive patterns
Strategy: validation
Validate before calling
function parseScale(raw: string | undefined): number | undefined {
if (!raw) return undefined
const n = Number(raw)
if (!Number.isFinite(n) || n <= 0) throw new Error('--scale must be a positive finite number')
return n
} Type guard
function isPositiveFinite(v: unknown): v is number {
return typeof v === 'number' && Number.isFinite(v) && v > 0
} Prevention
- Use --scale only when you need a real device pixel ratio (e.g. 2 for retina).
- Omit --scale to inherit the default rather than passing 0/1 speculatively.
- Validate scale at the script layer for non-numeric/empty inputs.
When it happens
Trigger: Running `browser-env viewport --width 1280 --height 720 --scale 0` (or negative, non-numeric, or Infinity). The `if (scale)` truthy gate then the finite/<=0 check fires.
Common situations: Passing a percentage ('100'), a non-numeric token, or 0 thinking it means 'default'. Shell expansion of an unset variable yielding an empty/non-numeric string.
Related errors
AI-assisted analysis of stablyai/orca@1136503c6a (2026-08-12).
Data as JSON: /api/errors/2b949c5143b3d093.
Report an issue: GitHub.