{"record":{"id":"274ac13ca568ed5a","repo":"huggingface/transformers","slug":"can-t-derive-true-or-false-from-v-key-k","errorCode":null,"errorMessage":"can't derive true or false from {v} (key {k})","messagePattern":"can't derive true or false from (.+?) \\(key (.+?)\\)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/transformers/configuration_utils.py","lineNumber":1196,"sourceCode":"\n        Args:\n            update_str (`str`): String with attributes that should be updated for this class.\n\n        \"\"\"\n\n        d = dict(x.split(\"=\") for x in update_str.split(\",\"))\n        for k, v in d.items():\n            if not hasattr(self, k):\n                raise ValueError(f\"key {k} isn't in the original config dict\")\n\n            old_v = getattr(self, k)\n            if isinstance(old_v, bool):\n                if v.lower() in [\"true\", \"1\", \"y\", \"yes\"]:\n                    v = True\n                elif v.lower() in [\"false\", \"0\", \"n\", \"no\"]:\n                    v = False\n                else:\n                    raise ValueError(f\"can't derive true or false from {v} (key {k})\")\n            elif isinstance(old_v, int):\n                v = int(v)\n            elif isinstance(old_v, float):\n                v = float(v)\n            elif not isinstance(old_v, str):\n                raise TypeError(\n                    f\"You can only update int, float, bool or string values in the config, got {v} for key {k}\"\n                )\n\n            setattr(self, k, v)\n\n    def dict_dtype_to_str(self, d: dict[str, Any]) -> None:\n        \"\"\"\n        Checks whether the passed dictionary and its nested dicts have a *dtype* key and if it's not None,\n        converts torch.dtype to a string of just the type. For example, `torch.float32` get converted into *\"float32\"*\n        string, which can then be stored in the json format.\n        \"\"\"\n        if d.get(\"dtype\") is not None:","sourceCodeStart":1178,"sourceCodeEnd":1214,"githubUrl":"https://github.com/huggingface/transformers/blob/a597f974857b3d92939971296bc0deb93d33d780/src/transformers/configuration_utils.py#L1178-L1214","documentation":"ValueError from update_from_string when the target attribute is a bool but the provided value string is not one of the accepted truthy/falsy tokens (true/1/y/yes or false/0/n/no, case-insensitive). The parser refuses to guess a boolean from arbitrary text.","triggerScenarios":"config.update_from_string(\"scale_attn_weights=maybe\"), or passing 'True ' with whitespace, or 'on/off', or 't/f' which are not in the accepted token list.","commonSituations":"User-supplied CLI flags flowed into the update string with unexpected spellings; values produced by shell substitution that include quotes or spaces.","solutions":["Use one of the accepted tokens: true/false, 1/0, y/n, yes/no (any casing).","Strip whitespace/quotes from each value before building the update string.","Set booleans directly: config.scale_attn_weights = True."],"exampleFix":"// before\nconfig.update_from_string(\"scale_attn_weights=on\")  # ValueError\n\n// after\nconfig.update_from_string(\"scale_attn_weights=true\")","handlingStrategy":"validation","validationCode":"BOOL_TOKENS = {\"true\", \"1\", \"y\", \"yes\", \"false\", \"0\", \"n\", \"no\"}\nfor k, v in parsed_pairs.items():\n    if isinstance(getattr(config, k, None), bool) and str(v).strip().lower() not in BOOL_TOKENS:\n        raise ValueError(f\"{k}={v!r} is not a recognized boolean token\")","typeGuard":"def is_bool_token(v: str) -> bool:\n    return v.strip().strip('\"\\'').lower() in {\"true\", \"1\", \"y\", \"yes\", \"false\", \"0\", \"n\", \"no\"}","tryCatchPattern":null,"preventionTips":["Normalize boolean inputs to true/false before composing update strings.","Strip whitespace and quotes from shell-provided values."],"tags":["config","update-from-string","boolean-parsing"],"backgroundTag":null,"analyzedSha":"a597f974857b3d92939971296bc0deb93d33d780","analyzedAt":"2026-08-14T18:24:08.354Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}