grafana/k6 · error
parsing setInputFiles options: %w
Error message
parsing setInputFiles options: %w
What it means
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.
Source
Thrown at internal/js/modules/k6/browser/browser/element_handle_mapping.go:233
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 := common.NewElementHandleSetCheckedOptions(eh.DefaultTimeout())
if err := popts.Parse(vu.Context(), opts); 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 := common.NewElementHandleSetInputFilesOptions(eh.DefaultTimeout())
if err := popts.Parse(vu.Context(), opts); 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 := common.NewElementHandleTapOptions(eh.Timeout())
if err := popts.Parse(vu.Context(), opts); 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 93accf6570)
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
Example fix
// before
await el.setInputFiles(file, { timeout: '5s' });
// after
await el.setInputFiles(file, { timeout: 5000 }); Defensive patterns
Strategy: try-catch
Validate before calling
const ALLOWED = new Set(['force', 'noWaitAfter', 'timeout']);
const bad = Object.keys(opts || {}).filter(k => !ALLOWED.has(k));
if (bad.length) console.warn(`setInputFiles(): unsupported options ignored: ${bad.join(', ')}`);
if (opts?.timeout !== undefined && !Number.isFinite(Number(opts.timeout))) {
throw new Error('setInputFiles(): timeout must be ms number');
} Type guard
function isSetInputFilesOpts(o) {
if (o == null) return true;
return (o.force === undefined || typeof o.force === 'boolean') &&
(o.noWaitAfter === undefined || typeof o.noWaitAfter === 'boolean') &&
(o.timeout === undefined || Number.isFinite(o.timeout));
} Try / catch
try {
await el.setInputFiles(files, opts);
} catch (e) {
if (/parsing setInputFiles options/.test(String(e.message))) {
console.log(`fix options object: ${e.message}`);
} else if (/parsing setInputFiles parameter/.test(String(e.message))) {
console.log(`fix files argument: ${e.message}`); // descriptor shape problem
} else throw e;
} Prevention
- 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
When it happens
Trigger: In current code none: force/noWaitAfter/timeout coerce any value; unknown keys are ignored.
Common situations: Time passed as '5s' instead of 5000 (silently coerced, leading to confusing timeouts); options written for old xk6-browser versions with structural parsing.
Related errors
- parsing check options: %w
- parsing element click options: %w
- parsing element double click options: %w
- parsing element fill options: %w
- parsing element hover options: %w
AI-assisted analysis of grafana/k6@93accf6570 (2026-08-15).
Data as JSON: /api/errors/fe61d6f259f0b2c7.
Report an issue: GitHub.