{"record":{"id":"7aa0487057caa438","repo":"reflex-dev/reflex","slug":"only-one-default-import-is-allowed","errorCode":null,"errorMessage":"Only one default import is allowed.","messagePattern":"Only one default import is allowed\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"reflex/compiler/utils.py","lineNumber":70,"sourceCode":"    Args:\n        fields: The set of fields to import from the library.\n\n    Returns:\n        The libraries for default and rest.\n        default: default library. When install \"import def from library\".\n        rest: rest of libraries. When install \"import {rest1, rest2} from library\"\n\n    Raises:\n        ValueError: If there is more than one default import.\n    \"\"\"\n    # ignore the ImportVar fields with render=False during compilation\n    fields_set = {field for field in fields if field.render}\n\n    # Check for default imports.\n    defaults = {field for field in fields_set if field.is_default}\n    if len(defaults) >= 2:\n        msg = \"Only one default import is allowed.\"\n        raise ValueError(msg)\n\n    # Get the default import, and the specific imports.\n    default = next(iter({field.name for field in defaults}), \"\")\n    rest = {field.name for field in fields_set - defaults}\n\n    return default, sorted(rest)\n\n\ndef validate_imports(import_dict: ParsedImportDict):\n    \"\"\"Verify that the same Tag is not used in multiple import.\n\n    Args:\n        import_dict: The dict of imports to validate\n\n    Raises:\n        ValueError: if a conflict on \"tag/alias\" is detected for an import.\n    \"\"\"\n    used_tags = {}","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/reflex-dev/reflex/blob/45b8ed5ab735f8a56bbb09a42384f030eb0208e7/reflex/compiler/utils.py#L52-L88","documentation":"compile_import_statement validates an ImportTag set and raises ValueError when two or more fields in a single import statement are marked as default imports. An ES module import can have only one default binding (e.g. import Def, { named } from 'mod'), so multiple defaults are ambiguous.","triggerScenarios":"Passing multiple fields with is_default=True for the same module when building an import statement, e.g. via custom components or libraries constructing ImportVar/ImportTag lists with several defaults; merging imports that each carry their own default tag for the same package.","commonSituations":"Custom component libraries or code generators emitting two default ImportVars for one module; Reflex version changes altering how default imports are declared (older field-based API vs newer ImportTag API) after an upgrade.","solutions":["Ensure only one field per module uses the default import; convert extras to named imports","Audit custom component code that builds import dicts manually and deduplicate default tags","After upgrading Reflex, regenerate or update import declarations to the current API (rxImportVar / ImportTag usage)"],"exampleFix":"# before\nimports = {\"react\": [ImportVar(tag=\"default\", is_default=True), ImportVar(tag=\"other\", is_default=True)]}\n# after\nimports = {\"react\": [ImportVar(tag=\"default\", is_default=True), ImportVar(tag=\"other\")]}","handlingStrategy":"validation","validationCode":"defaults = [f for f in fields if f.is_default]\nassert len(defaults) <= 1, \"only one default import per module\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Emit at most one default ImportVar/ImportTag per module","Deduplicate defaults when merging import dicts","Regenerate import code after Reflex upgrades"],"tags":["reflex","imports","compiler","valueerror"],"backgroundTag":"import-statement-validation-failed","analyzedSha":"45b8ed5ab735f8a56bbb09a42384f030eb0208e7","analyzedAt":"2026-08-28T19:25:27.644Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}