{"record":{"id":"67f4e79f8e777ab0","repo":"grafana/k6","slug":"parsing-file-descriptor-w","errorCode":null,"errorMessage":"parsing file descriptor: %w","messagePattern":"parsing file descriptor: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/element_handle_options.go","lineNumber":217,"sourceCode":"// NewElementHandleSetInputFilesOptions creates a new ElementHandleSetInputFilesOption.\nfunc NewElementHandleSetInputFilesOptions(defaultTimeout time.Duration) *ElementHandleSetInputFilesOptions {\n\treturn &ElementHandleSetInputFilesOptions{\n\t\tElementHandleBaseOptions: *NewElementHandleBaseOptions(defaultTimeout),\n\t}\n}\n\n// addFile to the struct. Input value can only be a file descriptor object.\nfunc (f *Files) addFile(ctx context.Context, file sobek.Value) error {\n\tif common.IsNullish(file) {\n\t\treturn nil\n\t}\n\trt := k6ext.Runtime(ctx)\n\tfileType := file.ExportType()\n\tswitch fileType.Kind() {\n\tcase reflect.Map: // file descriptor object\n\t\tvar parsedFile File\n\t\tif err := rt.ExportTo(file, &parsedFile); err != nil {\n\t\t\treturn fmt.Errorf(\"parsing file descriptor: %w\", err)\n\t\t}\n\t\tf.Payload = append(f.Payload, &parsedFile)\n\tdefault:\n\t\treturn fmt.Errorf(\"invalid parameter type : %s\", fileType.Kind().String())\n\t}\n\n\treturn nil\n}\n\n// Parse parses the Files struct from the given sobek.Value.\nfunc (f *Files) Parse(ctx context.Context, files sobek.Value) error {\n\trt := k6ext.Runtime(ctx)\n\tif common.IsNullish(files) {\n\t\treturn nil\n\t}\n\n\toptsType := files.ExportType()\n\tswitch optsType.Kind() {","sourceCodeStart":199,"sourceCodeEnd":235,"githubUrl":"https://github.com/grafana/k6/blob/8d06114777191d21ef885d05c5f8aa9e1ed838ae/internal/js/modules/k6/browser/common/element_handle_options.go#L199-L235","documentation":"Returned by Files.addFile when the setInputFiles payload member is an object but cannot be exported into the File struct (name/content/mimeType/types mismatch — e.g. content not decodable as base64 or string). This is user-input validation of the file descriptor passed from the k6 script.","triggerScenarios":"Thrown at internal/js/modules/k6/browser/common/element_handle_options.go:233 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Provide the file descriptor as {name, mimeType, data} with data as base64 (or use a file path form where supported)","Ensure content values are strings, not nested objects","Check required fields for the k6 version in use"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"8d06114777191d21ef885d05c5f8aa9e1ed838ae","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":"2026-08-18T03:05:52.393Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}