{"record":{"id":"398a0e94a534f633","repo":"jax-ml/jax","slug":"for-flags-with-a-corresponding-contextmanager-rea","errorCode":null,"errorMessage":"For flags with a corresponding contextmanager, read their value via e.g. `config.{name}` rather than `config.FLAGS.{name}`.","messagePattern":"For flags with a corresponding contextmanager, read their value via e\\.g\\. `config\\.(.+?)` rather than `config\\.FLAGS\\.(.+?)`\\.","errorType":"exception","errorClass":"AttributeError","httpStatus":null,"severity":"error","filePath":"jax/_src/config.py","lineNumber":103,"sourceCode":"      ...\n\n    def __setattr__(self, name: str, value: Any) -> None:\n      ...\n\n  def __init__(self):\n    self._value_holders: dict[str, ValueHolder] = {}\n    self.meta = {}\n    self.use_absl = False\n    self._contextmanager_flags = set()\n\n  def update(self, name, val):\n    if name not in self._value_holders:\n      raise AttributeError(f\"Unrecognized config option: {name}\")\n    self._value_holders[name]._set(val)\n\n  def read(self, name):\n    if name in self._contextmanager_flags:\n      raise AttributeError(\n          \"For flags with a corresponding contextmanager, read their value \"\n          f\"via e.g. `config.{name}` rather than `config.FLAGS.{name}`.\")\n    return self._read(name)\n\n  def _read(self, name):\n    try:\n      return self._value_holders[name].value\n    except KeyError:\n      raise AttributeError(f\"Unrecognized config option: {name}\")\n\n  @property\n  def values(self):\n    return {name: holder.value for name, holder in self._value_holders.items()}\n\n  def add_option(self, name, holder, opt_type, meta_args, meta_kwargs):\n    if name in self._value_holders:\n      raise Exception(f\"Config option {name} already defined\")\n    self._value_holders[name] = holder","sourceCodeStart":85,"sourceCodeEnd":121,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/config.py#L85-L121","documentation":"Flags defined with a corresponding context manager must be read through their property on the config object (e.g. jax.config.jax_enable_x64) rather than through the absl-style FLAGS proxy (config.FLAGS.jax_enable_x64). Reading via FLAGS would bypass thread-local/context-local semantics, so config.read explicitly raises AttributeError to redirect the caller.","triggerScenarios":"Accessing jax.config.FLAGS.<option_name> for any option registered with a context manager (most modern thread-local JAX options like jax_enable_x64, jax_numpy_rank_promotion).","commonSituations":"Migrating old code that read config.FLAGS in the pre-thread-local JAX config era; absl flag introspection code iterating over FLAGS attributes.","solutions":["Replace config.FLAGS.name with config.name (e.g. jax.config.jax_enable_x64)","For programmatic access use jax.config.read(name) only for non-contextmanager flags, or getattr(jax.config, name)","If you need the absl flag value, read the absl flag itself (absl.flags.FLAGS['jax_enable_x64'].value) rather than config.FLAGS"],"exampleFix":"# before\nif jax.config.FLAGS.jax_enable_x64: ...\n# after\nif jax.config.jax_enable_x64: ...","handlingStrategy":"validation","validationCode":"import jax\n\ndef cfg_get(name):\n    # always read via attribute, never FLAGS\n    return getattr(jax.config, name)\n\nassert cfg_get('jax_enable_x64') in (True, False)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never access jax.config.FLAGS.<thread-local option>; use jax.config.<option>","Grep your codebase for 'config.FLAGS.' during JAX upgrades","Use absl.flags directly if you truly need the absl flag value"],"tags":["jax","config","contextmanager","api-migration"],"backgroundTag":"deprecated-config-access","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}