{"record":{"id":"cc1d12c8587c2e42","repo":"reflex-dev/reflex","slug":"event-handler-self-fn-name-received-multiple","errorCode":null,"errorMessage":"Event handler {self.fn.__name__} received multiple file upload arguments.","messagePattern":"Event handler (.+?) received multiple file upload arguments\\.","errorType":"exception","errorClass":"EventHandlerTypeError","httpStatus":null,"severity":"error","filePath":"packages/reflex-base/src/reflex_base/event/__init__.py","lineNumber":660,"sourceCode":"            raise EventHandlerTypeError(msg)\n\n        fn_args = fn_args[: len(args)] + list(kwargs)\n        event_args = [*args, *kwargs.values()]\n\n        # Construct the payload.\n        payload = []\n        upload_event_spec = None\n        for fn_arg, arg in zip(fn_args, event_args, strict=False):\n            # Special case for file uploads. The upload arg takes its own\n            # positional slot so the remaining args stay aligned with fn_args,\n            # but its parameter name is re-derived server-side in as_event_spec.\n            if isinstance(arg, (FileUpload, UploadFilesChunk)):\n                if upload_event_spec is not None:\n                    msg = (\n                        f\"Event handler {self.fn.__name__} received multiple file \"\n                        \"upload arguments.\"\n                    )\n                    raise EventHandlerTypeError(msg)\n                upload_event_spec = arg.as_event_spec(handler=self)\n                continue\n\n            # Otherwise, convert to JSON.\n            try:\n                payload.append((Var(_js_expr=fn_arg), LiteralVar.create(arg)))\n            except TypeError as e:\n                msg = f\"Arguments to event handlers must be Vars or JSON-serializable. Got {arg} of type {type(arg)}.\"\n                raise EventHandlerTypeError(msg) from e\n\n        if upload_event_spec is not None:\n            if not payload:\n                return upload_event_spec\n            # The extra bound args share the flat payload with the synthetic\n            # upload args, so reject names that would clobber a reserved upload\n            # key (files, upload_id, extra_headers, ...).\n            payload_names = [name._js_expr for name, _ in payload]\n            reserved = {name._js_expr for name, _ in upload_event_spec.args}","sourceCodeStart":642,"sourceCodeEnd":678,"githubUrl":"https://github.com/reflex-dev/reflex/blob/45b8ed5ab735f8a56bbb09a42384f030eb0208e7/packages/reflex-base/src/reflex_base/event/__init__.py#L642-L678","documentation":"A single event-handler call may accept only one file-upload construct (rx.upload_files(...) or rx.upload_files_chunk(...)). Passing two means the framework cannot build one coherent upload event spec.","triggerScenarios":"Calling a handler with two arguments that are FileUpload/UploadFilesChunk instances, e.g. State.up(rx.upload_files(State.h1), rx.upload_files_chunk(State.h2)).","commonSituations":"Trying to upload two different file sets in one event, or accidentally leaving an old rx.upload_files call in when migrating to chunked uploads.","solutions":["Split into two separate event-handler calls","Combine both uploads into a single rx.upload_files / rx.upload_files_chunk argument","Drop the stale upload argument left over from migration"],"exampleFix":"# before\nState.upload(rx.upload_files(State.h1), rx.upload_files_chunk(State.h2))\n# after\nState.upload(rx.upload_files(State.h1)); State.upload_chunked(rx.upload_files_chunk(State.h2))","handlingStrategy":"validation","validationCode":"from reflex_base.event import FileUpload, UploadFilesChunk\n\ndef count_upload_args(args):\n    return sum(1 for a in args if isinstance(a, (FileUpload, UploadFilesChunk)))\n# assert count_upload_args(args) <= 1 before calling","typeGuard":null,"tryCatchPattern":null,"preventionTips":["One upload spec per event call; chain separate calls for multiple uploads"],"tags":["reflex","file-upload","event-handler","argument-error"],"backgroundTag":"api-misuse-validation","analyzedSha":"45b8ed5ab735f8a56bbb09a42384f030eb0208e7","analyzedAt":"2026-08-28T19:25:27.644Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}