grafana/k6 · error
parsing setInputFiles options
Error message
parsing setInputFiles options: %w
What it means
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.
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
Example fix
// before
await handle.setInputFiles(file, '5000');
// after
await handle.setInputFiles(file, { timeout: 5000 }); Defensive patterns
Strategy: try-catch
Validate before calling
if (opts != null && typeof opts !== 'object') {
throw new Error(`setInputFiles options must be an object, got ${typeof opts}`);
}
await handle.setInputFiles(files, opts); Type guard
function isPlainOptions(v) {
return v == null || (typeof v === 'object' && !Array.isArray(v));
} Try / catch
try {
await handle.setInputFiles(files, opts);
} catch (e) {
if (String(e).includes('parsing setInputFiles options')) {
// wrap is defensive; log the inner error and fall back to no options
await handle.setInputFiles(files);
} else { throw e; }
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- parsing element tap options
- parsing setChecked options
- parsing setInputFiles parameter
- parsing type options
- parsing uncheck options
AI-assisted analysis of grafana/k6@3fcf5388d7 (2026-09-14).
Data as JSON: /api/errors/fe61d6f259f0b2c7.
Report an issue: GitHub.
Appendix: source
Thrown at internal/js/modules/k6/browser/browser/element_handle_mapping.go:240
return nil, fmt.Errorf("parsing selectText options: %w", err)
}
return promise(vu, func() (any, error) {
return nil, eh.SelectText(popts) //nolint:wrapcheck
}), nil
},
"setChecked": func(checked bool, opts sobek.Value) (*sobek.Promise, error) {
popts, err := parseElementHandleSetCheckedOptions(rt, opts, eh.DefaultTimeout())
if err != nil {
return nil, fmt.Errorf("parsing setChecked options: %w", err)
}
return promise(vu, func() (any, error) {
return nil, eh.SetChecked(checked, popts) //nolint:wrapcheck
}), nil
},
"setInputFiles": func(files sobek.Value, opts sobek.Value) (*sobek.Promise, error) {
popts, err := parseElementHandleSetInputFilesOptions(rt, opts, eh.DefaultTimeout())
if err != nil {
return nil, fmt.Errorf("parsing setInputFiles options: %w", err)
}
var pfiles common.Files
if err := pfiles.Parse(vu.Context(), files); err != nil {
return nil, fmt.Errorf("parsing setInputFiles parameter: %w", err)
}
return promise(vu, func() (any, error) {
return nil, eh.SetInputFiles(&pfiles, popts) //nolint:wrapcheck
}), nil
},
"tap": func(opts sobek.Value) (*sobek.Promise, error) {
popts, err := parseElementHandleTapOptions(rt, opts, eh.Timeout())
if err != nil {
return nil, fmt.Errorf("parsing element tap options: %w", err)
}
return promise(vu, func() (any, error) {
return nil, eh.Tap(popts) //nolint:wrapcheck
}), nil
},View on GitHub (pinned to 3fcf5388d7)