{"record":{"id":"634ef0e53e1be1e0","repo":"HKUDS/Vibe-Trading","slug":"unknown-structure-self-structure-r-expected-one","errorCode":null,"errorMessage":"unknown structure {self.structure!r}; expected one of: {valid}","messagePattern":"unknown structure (.+?); expected one of: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"agent/src/entities/models.py","lineNumber":304,"sourceCode":"    structure: FundStructure = FundStructure.CLOSED_END\n    strategy: str = \"\"\n    commitment: float | None = None\n    management_fee_rate: float | None = None\n\n    def __post_init__(self) -> None:\n        \"\"\"Validate the base fields plus fund-specific ranges.\n\n        Raises:\n            ValueError: If ``structure`` is unknown, ``commitment`` is\n                negative, ``management_fee_rate`` is out of ``[0, 1]``, or\n                ``vintage_year`` is implausible.\n        \"\"\"\n        super().__post_init__()\n        try:\n            object.__setattr__(self, \"structure\", FundStructure(self.structure))\n        except ValueError as exc:\n            valid = \", \".join(member.value for member in FundStructure)\n            raise ValueError(\n                f\"unknown structure {self.structure!r}; expected one of: {valid}\"\n            ) from exc\n        if self.vintage_year is not None and not 1800 <= int(self.vintage_year) <= 2200:\n            raise ValueError(\n                f\"vintage_year={self.vintage_year!r} is outside the plausible \"\n                \"range 1800-2200\"\n            )\n        if self.commitment is not None:\n            if float(self.commitment) < 0:\n                raise ValueError(\n                    f\"commitment must be non-negative (it is a size, not a signed \"\n                    f\"cash flow), got {self.commitment!r}\"\n                )\n            object.__setattr__(self, \"commitment\", float(self.commitment))\n        if self.management_fee_rate is not None:\n            rate = float(self.management_fee_rate)\n            if not 0.0 <= rate <= 1.0:\n                raise ValueError(","sourceCodeStart":286,"sourceCodeEnd":322,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/entities/models.py#L286-L322","documentation":"Fund.__post_init__ validates the structure field against the FundStructure enum; a string that is not an exact member value raises ValueError listing valid structures (e.g. open-ended vs closed-ended).","triggerScenarios":"Fund(..., structure='Open Ended'), structure='closed' (abbreviation), or any typo/whitespace variant. The enum call happens after super().__post_init__(), so instrument-level validation has already passed.","commonSituations":"Fund reference data sourced from documents or spreadsheets using prose labels; a data vendor that abbreviates structures; enum renames between releases leaving stale stored values.","solutions":["Use a FundStructure member or its exact value","Normalize structure strings (strip/case-fold) and map aliases before construction","Extend FundStructure if a legitimate structure variant is missing"],"exampleFix":"# before\nFund(instrument_id='f1', structure='open-ended')\n\n# after\nFund(instrument_id='f1', structure=FundStructure.OPEN_ENDED.value)","handlingStrategy":"validation","validationCode":"from agent.src.entities.models import FundStructure\nstructure = row['structure'].strip().lower()\nstructure = {'open-ended': FundStructure.OPEN_ENDED.value, ...}.get(structure, structure)\nFundStructure(structure)  # raises early with your own context if still bad","typeGuard":"from agent.src.entities.models import FundStructure\n\ndef is_valid_fund_structure(v: str) -> bool:\n    try:\n        FundStructure(v)\n        return True\n    except ValueError:\n        return False","tryCatchPattern":"try:\n    f = Fund(instrument_id=iid, structure=structure, ...)\nexcept ValueError as exc:\n    if 'unknown structure' in str(exc):\n        log.warning('bad fund structure %r on %s', structure, iid)\n        continue\n    raise","preventionTips":["Map prose fund-structure labels to canonical enum values before loading","Validate once during data-profiling, not per object in production loops"],"tags":["python","dataclass","enum-validation","funds"],"backgroundTag":"enum-value-validation","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}