{"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":240,"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, err := parseElementHandleSetCheckedOptions(rt, opts, eh.DefaultTimeout())\n\t\t\tif 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, err := parseElementHandleSetInputFilesOptions(rt, opts, eh.DefaultTimeout())\n\t\t\tif 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, err := parseElementHandleTapOptions(rt, opts, eh.Timeout())\n\t\t\tif 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":222,"sourceCodeEnd":258,"githubUrl":"https://github.com/grafana/k6/blob/3fcf5388d78cb382f0c0d42ec556a06bfd1b8dee/internal/js/modules/k6/browser/browser/element_handle_mapping.go#L222-L258","documentation":"Thrown when ElementHandle.setInputFiles cannot parse its second (options) argument. ElementHandleSetInputFilesOptions embeds only ElementHandleBaseOptions, whose Parse coerces force/noWaitAfter/timeout via sobek coercion and never type-fails, and unknown keys are ignored. This wrap is defensive: in current code the wrapped Parse has no realistic error path, so seeing it usually indicates an internal/runtime problem rather than a bad options key.","triggerScenarios":"Calling handle.setInputFiles(files, opts) where opts is a primitive (number, string, symbol) that cannot be coerced to an object, or a runtime-level export failure inside ElementHandleBaseOptions.Parse. Passing a normal object, null, or undefined never triggers it.","commonSituations":"Almost never seen in the wild; the options keys force/noWaitAfter/timeout are coercion-tolerant and typos are silently ignored. If it appears, suspect a modified/older k6 build or an options value that is not a plain object.","solutions":["Pass the options argument as a plain object, null, or undefined: setInputFiles(files, {timeout: 5000}) or setInputFiles(files)","If it persists with a plain object, check the actual error being wrapped (%w) — it points inside the runtime, not at your options keys","Report as a k6 browser module bug if reproducible with an ordinary object"],"exampleFix":"// before\nawait handle.setInputFiles(file, '5000');\n// after\nawait handle.setInputFiles(file, { timeout: 5000 });","handlingStrategy":"try-catch","validationCode":"if (opts != null && typeof opts !== 'object') {\n  throw new Error(`setInputFiles options must be an object, got ${typeof opts}`);\n}\nawait handle.setInputFiles(files, opts);","typeGuard":"function isPlainOptions(v) {\n  return v == null || (typeof v === 'object' && !Array.isArray(v));\n}","tryCatchPattern":"try {\n  await handle.setInputFiles(files, opts);\n} catch (e) {\n  if (String(e).includes('parsing setInputFiles options')) {\n    // wrap is defensive; log the inner error and fall back to no options\n    await handle.setInputFiles(files);\n  } else { throw e; }\n}","preventionTips":["Always pass the second argument as an object, null, or undefined","Lint call sites so no primitive sneaks into an options slot","Keep shared option constants typed as objects"],"tags":["k6","browser","element-handle","setinputfiles","options"],"backgroundTag":"options-validation-failed","analyzedSha":"3fcf5388d78cb382f0c0d42ec556a06bfd1b8dee","analyzedAt":"2026-09-14T20:10:14.619Z","contentChangedAt":"2026-09-14T20:10:14.619Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}