{"record":{"id":"db7f1bc0c980072f","repo":"tensorflow/models","slug":"type-r-is-not-a-valid-key","errorCode":null,"errorMessage":"type: {!r} is not a valid key!","messagePattern":"type: (.+?) is not a valid key!","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/modeling/hyperparams/oneof.py","lineNumber":40,"sourceCode":"\n@dataclasses.dataclass\nclass OneOfConfig(base_config.Config):\n  \"\"\"Configuration for configs with one of feature.\n\n  Attributes:\n    type: 'str', name of the field to select.\n  \"\"\"\n  type: Optional[str] = None\n\n  def as_dict(self):\n    \"\"\"Returns a dict representation of OneOfConfig.\n\n    For the nested base_config.Config, a nested dict will be returned.\n    \"\"\"\n    if self.type is None:\n      return {'type': None}\n    elif self.__dict__['type'] not in self.__dict__:\n      raise ValueError('type: {!r} is not a valid key!'.format(\n          self.__dict__['type']))\n    else:\n      chosen_type = self.type\n      chosen_value = self.__dict__[chosen_type]\n      return {'type': self.type, chosen_type: self._export_config(chosen_value)}\n\n  def get(self):\n    \"\"\"Returns selected config based on the value of type.\n\n    If type is not set (None), None is returned.\n    \"\"\"\n    chosen_type = self.type\n    if chosen_type is None:\n      return None\n    if chosen_type not in self.__dict__:\n      raise ValueError('type: {!r} is not a valid key!'.format(self.type))\n    return self.__dict__[chosen_type]\n","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/modeling/hyperparams/oneof.py#L22-L58","documentation":"Error \"type: {!r} is not a valid key!\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/modeling/hyperparams/oneof.py:40 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e006f5f0d534913e49c1f1dae87364039fa607e2","analyzedAt":"2026-08-24T14:09:15.576Z","schemaVersion":2},"datasetVersion":"2026-08-24T17:17:21.512Z"}