{"record":{"id":"cf05cc71e1083024","repo":"tensorflow/models","slug":"the-key-does-not-exist-to-extend-the-existi","errorCode":null,"errorMessage":"The key `%{}` does not exist. To extend the existing keys, use `override` with `is_strict` = True.","messagePattern":"The key `%(.+?)` does not exist\\. To extend the existing keys, use `override` with `is_strict` = True\\.","errorType":"exception","errorClass":"KeyError","httpStatus":null,"severity":"error","filePath":"official/modeling/hyperparams/params_dict.py","lineNumber":115,"sourceCode":"    else:\n      self.__dict__[k] = copy.deepcopy(v)\n\n  def __setattr__(self, k, v):\n    \"\"\"Sets the value of the existing key.\n\n    Note that this does not allow directly defining a new key. Use the\n    `override` method with `is_strict=False` instead.\n\n    Args:\n      k: the key string.\n      v: the value to be used to set the key `k`.\n\n    Raises:\n      KeyError: if k is not defined in the ParamsDict.\n    \"\"\"\n    if k not in ParamsDict.RESERVED_ATTR:\n      if k not in self.__dict__.keys():\n        raise KeyError('The key `%{}` does not exist. '\n                       'To extend the existing keys, use '\n                       '`override` with `is_strict` = True.'.format(k))\n      if self._locked:\n        raise ValueError('The ParamsDict has been locked. '\n                         'No change is allowed.')\n    self._set(k, v)\n\n  def __getattr__(self, k):\n    \"\"\"Gets the value of the existing key.\n\n    Args:\n      k: the key string.\n\n    Returns:\n      the value of the key.\n\n    Raises:\n      AttributeError: if k is not defined in the ParamsDict.","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/modeling/hyperparams/params_dict.py#L97-L133","documentation":"Unknown-key guard in ParamsDict.__setattr__: assignment targets a key not present in the dict. Direct attribute assignment cannot create keys by design; only override(is_strict=False) extends a ParamsDict. (The message's suggestion text says is_strict=True, but extending requires False.)","triggerScenarios":"Thrown at official/modeling/hyperparams/params_dict.py:115 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use override({'key': value}, is_strict=False) to add the key","Verify the key name exists in the ParamsDict before assigning"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e006f5f0d534913e49c1f1dae87364039fa607e2","analyzedAt":"2026-08-24T14:09:15.576Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}