{"record":{"id":"b750b01f2acd1b3c","repo":"remotion-dev/remotion","slug":"topk-must-be-a-non-negative-integer","errorCode":null,"errorMessage":"topK must be a non-negative integer.","messagePattern":"topK must be a non-negative integer\\.","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/whisper-webgpu/src/transcribe.ts","lineNumber":95,"sourceCode":"\t\tthrow new Error(\n\t\t\t'strideLengthInSeconds must be a finite, non-negative number and less than half of chunkLengthInSeconds.',\n\t\t);\n\t}\n\n\tif (typeof forceFullSequences !== 'boolean') {\n\t\tthrow new TypeError('forceFullSequences must be a boolean.');\n\t}\n\n\tif (typeof doSample !== 'boolean') {\n\t\tthrow new TypeError('doSample must be a boolean.');\n\t}\n\n\tif (!Number.isFinite(temperature) || temperature <= 0) {\n\t\tthrow new TypeError('temperature must be a finite number greater than 0.');\n\t}\n\n\tif (!Number.isInteger(topK) || topK < 0) {\n\t\tthrow new TypeError('topK must be a non-negative integer.');\n\t}\n\n\tif (!Number.isFinite(repetitionPenalty) || repetitionPenalty <= 0) {\n\t\tthrow new TypeError(\n\t\t\t'repetitionPenalty must be a finite number greater than 0.',\n\t\t);\n\t}\n\n\tif (!Number.isInteger(noRepeatNgramSize) || noRepeatNgramSize < 0) {\n\t\tthrow new TypeError('noRepeatNgramSize must be a non-negative integer.');\n\t}\n\n\tif (task !== 'transcribe' && task !== 'translate') {\n\t\tthrow new TypeError('task must be either \"transcribe\" or \"translate\".');\n\t}\n\n\tconst {multilingual, supportsTranslation} = getModelInfo(model);\n\tif (task === 'translate' && !supportsTranslation) {","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/remotion-dev/remotion/blob/b2f4e34732f3c6c222ea029413e22dc402218cd7/packages/whisper-webgpu/src/transcribe.ts#L77-L113","documentation":"transcribe() validates the sampling option topK: it must be an integer >= 0 (0 typically disables top-K sampling). Fractional, negative, or non-number values are rejected with a TypeError before transcription starts.","triggerScenarios":"Passing topK as a float (e.g. 5.5), a negative number, NaN from parsing, or a string from config.","commonSituations":"Numeric strings from CLI/JSON options not converted; computing topK dynamically and producing NaN; confusing 0 semantics (0 may mean disabled — it is allowed as non-negative).","solutions":["Pass an integer >= 0, e.g. topK: 5","Convert with Math.max(0, Math.round(Number(raw))) after parsing","Validate numeric inputs from config files before constructing options"],"exampleFix":"// before\nawait transcribe({topK: '50'});\n// after\nawait transcribe({topK: Math.round(Number(rawTopK))});","handlingStrategy":"validation","validationCode":"if (!Number.isInteger(topK) || topK < 0) throw new Error('topK must be a non-negative integer');","typeGuard":"const isNonNegInt = (v: unknown): v is number => typeof v === 'number' && Number.isInteger(v) && v >= 0;","tryCatchPattern":"try {\n  await transcribe(options);\n} catch (e) {\n  if (e instanceof TypeError && e.message.includes('topK')) {\n    options.topK = 5;\n  } else throw e;\n}","preventionTips":["Round parsed values before assigning integer options","Sanitize dynamic computations for NaN","Define a single options-normalization step for all numeric sampling params"],"tags":["validation","sampling","whisper"],"backgroundTag":"argument-out-of-range","analyzedSha":"b2f4e34732f3c6c222ea029413e22dc402218cd7","analyzedAt":"2026-09-09T13:27:51.281Z","contentChangedAt":"2026-09-09T13:27:51.281Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}