{"record":{"id":"fe61d6f259f0b2c7","repo":"grafana/k6","slug":"parsing-setinputfiles-options-w","errorCode":null,"errorMessage":"parsing setInputFiles options: %w","messagePattern":"parsing setInputFiles options: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/browser/element_handle_mapping.go","lineNumber":233,"sourceCode":"\t\t\t\treturn nil, fmt.Errorf(\"parsing selectText options: %w\", err)\n\t\t\t}\n\t\t\treturn promise(vu, func() (any, error) {\n\t\t\t\treturn nil, eh.SelectText(popts) //nolint:wrapcheck\n\t\t\t}), nil\n\t\t},\n\t\t\"setChecked\": func(checked bool, opts sobek.Value) (*sobek.Promise, error) {\n\t\t\tpopts := common.NewElementHandleSetCheckedOptions(eh.DefaultTimeout())\n\t\t\tif err := popts.Parse(vu.Context(), opts); err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"parsing setChecked options: %w\", err)\n\t\t\t}\n\t\t\treturn promise(vu, func() (any, error) {\n\t\t\t\treturn nil, eh.SetChecked(checked, popts) //nolint:wrapcheck\n\t\t\t}), nil\n\t\t},\n\t\t\"setInputFiles\": func(files sobek.Value, opts sobek.Value) (*sobek.Promise, error) {\n\t\t\tpopts := common.NewElementHandleSetInputFilesOptions(eh.DefaultTimeout())\n\t\t\tif err := popts.Parse(vu.Context(), opts); err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"parsing setInputFiles options: %w\", err)\n\t\t\t}\n\t\t\tvar pfiles common.Files\n\t\t\tif err := pfiles.Parse(vu.Context(), files); err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"parsing setInputFiles parameter: %w\", err)\n\t\t\t}\n\t\t\treturn promise(vu, func() (any, error) {\n\t\t\t\treturn nil, eh.SetInputFiles(&pfiles, popts) //nolint:wrapcheck\n\t\t\t}), nil\n\t\t},\n\t\t\"tap\": func(opts sobek.Value) (*sobek.Promise, error) {\n\t\t\tpopts := common.NewElementHandleTapOptions(eh.Timeout())\n\t\t\tif err := popts.Parse(vu.Context(), opts); err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"parsing element tap options: %w\", err)\n\t\t\t}\n\t\t\treturn promise(vu, func() (any, error) {\n\t\t\t\treturn nil, eh.Tap(popts) //nolint:wrapcheck\n\t\t\t}), nil\n\t\t},","sourceCodeStart":215,"sourceCodeEnd":251,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/js/modules/k6/browser/browser/element_handle_mapping.go#L215-L251","documentation":"Thrown synchronously by ElementHandle.setInputFiles() when the trailing options object fails to parse. It parses common.ElementHandleSetInputFilesOptions, which only embeds ElementHandleBaseOptions (force, noWaitAfter, timeout); that Parse is lenient coercion and always returns nil, so this wrap is defensive in current k6. The files argument itself is covered by the separate 'parsing setInputFiles parameter' error.","triggerScenarios":"In current code none: force/noWaitAfter/timeout coerce any value; unknown keys are ignored.","commonSituations":"Time passed as '5s' instead of 5000 (silently coerced, leading to confusing timeouts); options written for old xk6-browser versions with structural parsing.","solutions":["Keep options to { force, noWaitAfter, timeout } with numeric milliseconds","Put file descriptors in the first argument using { name, mimeType, buffer } objects","Upgrade k6 if this message appears; current Parse cannot fail here","Check the wrapped cause after the colon"],"exampleFix":"// before\nawait el.setInputFiles(file, { timeout: '5s' });\n\n// after\nawait el.setInputFiles(file, { timeout: 5000 });","handlingStrategy":"try-catch","validationCode":"const ALLOWED = new Set(['force', 'noWaitAfter', 'timeout']);\nconst bad = Object.keys(opts || {}).filter(k => !ALLOWED.has(k));\nif (bad.length) console.warn(`setInputFiles(): unsupported options ignored: ${bad.join(', ')}`);\nif (opts?.timeout !== undefined && !Number.isFinite(Number(opts.timeout))) {\n  throw new Error('setInputFiles(): timeout must be ms number');\n}","typeGuard":"function isSetInputFilesOpts(o) {\n  if (o == null) return true;\n  return (o.force === undefined || typeof o.force === 'boolean') &&\n         (o.noWaitAfter === undefined || typeof o.noWaitAfter === 'boolean') &&\n         (o.timeout === undefined || Number.isFinite(o.timeout));\n}","tryCatchPattern":"try {\n  await el.setInputFiles(files, opts);\n} catch (e) {\n  if (/parsing setInputFiles options/.test(String(e.message))) {\n    console.log(`fix options object: ${e.message}`);\n  } else if (/parsing setInputFiles parameter/.test(String(e.message))) {\n    console.log(`fix files argument: ${e.message}`); // descriptor shape problem\n  } else throw e;\n}","preventionTips":["The options object only takes force/noWaitAfter/timeout; file content belongs in the first argument","Distinguish the two error texts: 'options' = second argument, 'parameter' = files argument","Current k6 cannot fail the options parse; occurrence signals an old binary"],"tags":["k6","browser","element-handle","set-input-files","option-parsing"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}