{"record":{"id":"d95bb9870958daa2","repo":"PrefectHQ/fastmcp","slug":"fileupload-requires-prefab-ui-install-with-pip-i","errorCode":null,"errorMessage":"FileUpload requires prefab-ui. Install with: pip install 'fastmcp[apps]'","messagePattern":"FileUpload requires prefab-ui\\. Install with: pip install 'fastmcp\\[apps\\]'","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"fastmcp_slim/fastmcp/apps/file_upload.py","lineNumber":58,"sourceCode":"        H3,\n        Badge,\n        Button,\n        Card,\n        CardContent,\n        CardFooter,\n        CardHeader,\n        Column,\n        DropZone,\n        Muted,\n        Row,\n        Separator,\n        Small,\n        Text,\n    )\n    from prefab_ui.components.control_flow import Else, ForEach, If\n    from prefab_ui.rx import ERROR, RESULT, STATE, Rx\nexcept ImportError as _exc:\n    raise ImportError(\n        \"FileUpload requires prefab-ui. Install with: pip install 'fastmcp[apps]'\"\n    ) from _exc\n\nimport base64\nfrom datetime import datetime, timezone\nfrom typing import Any\n\nfrom fastmcp.apps.app import FastMCPApp\nfrom fastmcp.server.context import Context\n\n_TEXT_EXTENSIONS = frozenset(\n    (\".csv\", \".json\", \".txt\", \".md\", \".py\", \".yaml\", \".yml\", \".toml\")\n)\n\n\ndef _b64_decoded_size(b64: str) -> int:\n    \"\"\"Return the exact decoded byte-length of a base64 string without decoding it.\"\"\"\n    n = len(b64)","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/PrefectHQ/fastmcp/blob/1f021142978e0861cd910c8df4e8074bc7cf3978/fastmcp_slim/fastmcp/apps/file_upload.py#L40-L76","documentation":"fastmcp.apps.file_upload imports prefab-ui components (Small, Text, Else/ForEach/If, rx values) at module load. Without prefab_ui installed, the ImportError is re-raised with this install hint, so the FileUpload app cannot be used until the optional extra is present.","triggerScenarios":"`from fastmcp.apps.file_upload import FileUpload` or any import of the module in an environment lacking prefab-ui.","commonSituations":"Production images without the [apps] extra; missing dependency after dependency refresh; trying FileUpload from a minimal fastmcp install.","solutions":["Install with: `pip install 'fastmcp[apps]'`.","Verify prefab_ui is importable in the running interpreter/venv.","Gate the import of file_upload behind an availability check if prefab-ui is optional in your app."],"exampleFix":"// before\nfrom fastmcp.apps.file_upload import FileUpload\n// after\npip install 'fastmcp[apps]'\nfrom fastmcp.apps.file_upload import FileUpload","handlingStrategy":"fallback","validationCode":"try:\n    import prefab_ui  # noqa\nexcept ImportError:\n    prefab_ui = None","typeGuard":null,"tryCatchPattern":"try:\n    from fastmcp.apps.file_upload import FileUpload\nexcept ImportError as e:\n    FileUpload = None\n    logger.warning(\"FileUpload unavailable: install 'fastmcp[apps]'\")","preventionTips":["Install 'fastmcp[apps]' wherever file upload UIs are used","Check `pip show prefab-ui` in deployment scripts","Conditionally enable file-upload routes based on prefab_ui availability"],"tags":["python","importerror","optional-dependency"],"backgroundTag":"missing-optional-dependency","analyzedSha":"1f021142978e0861cd910c8df4e8074bc7cf3978","analyzedAt":"2026-08-29T14:31:16.082Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}