{"record":{"id":"f385e0d3484bbed9","repo":"jax-ml/jax","slug":"invalid-value-default-for-jax-flag-name","errorCode":null,"errorMessage":"Invalid value \"{default}\" for JAX flag {name}","messagePattern":"Invalid value \"(.+?)\" for JAX flag (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"jax/_src/config.py","lineNumber":509,"sourceCode":"      option.\n    default: string, default value.\n    help: string, used to populate the flag help information as well as the\n      docstring of the returned context manager.\n    include_in_jit_key: bool, optional: whether to include the state in the\n      JIT cache key.\n    extra_validator: optional function to validate the value of the config\n      option.\n\n  Returns:\n    A contextmanager to control the thread-local state value.\n  \"\"\"\n  if not isinstance(default, str):\n    raise TypeError(f\"Default value must be of type str, got {default} \"\n                    f\"of type {getattr(type(default), '__name__', type(default))}\")\n  name = name.lower()\n  default = os.getenv(name.upper(), default)\n  if default not in enum_values:\n    raise ValueError(f\"Invalid value \\\"{default}\\\" for JAX flag {name}\")\n  config._contextmanager_flags.add(name)\n\n  def parser(new_val):\n    if type(new_val) is not str or new_val not in enum_values:\n      raise ValueError(f\"new enum value must be in {enum_values}, \"\n                       f\"got {new_val} of type {type(new_val)}.\")\n    if extra_validator is not None:\n      extra_validator(new_val)\n    return new_val\n\n  s = State[str](\n      name,\n      default,\n      help,\n      update_global_hook=update_global_hook,\n      update_thread_local_hook=update_thread_local_hook,\n      parser=parser,\n      include_in_jit_key=include_in_jit_key,","sourceCodeStart":491,"sourceCodeEnd":527,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/config.py#L491-L527","documentation":"enum_state validates that the flag's default value (after checking the uppercase environment variable override) is one of the declared enum_values. If the env var JAX_<FLAG> is set to something outside enum_values, this ValueError is raised at flag definition (typically at jax import).","triggerScenarios":"Defining config.enum_state('my_flag', default='foo', enum_values=['foo','bar']) while JAX_MY_FLAG=baz is exported in the environment; or passing a default not in enum_values.","commonSituations":"A stale or misspelled JAX_* environment variable from a previous experiment or an old jax version whose accepted values changed (e.g. JAX_PYTHON_PREALLOCATE spellings, backend flag values).","solutions":["Check the exact flag name and fix/unset the offending JAX_<FLAG> env var: env | grep JAX_","Make sure `default` itself is one of enum_values","Update the value to one supported by your jax version (see the flag's help text)"],"exampleFix":"# before\nexport JAX_MY_FLAG=baz  # invalid\n# after\nexport JAX_MY_FLAG=foo  # one of enum_values","handlingStrategy":"validation","validationCode":"import os\nval = os.getenv('JAX_MY_FLAG')\nif val is not None and val not in enum_values:\n    raise RuntimeError(f'JAX_MY_FLAG={val!r} invalid; allowed: {enum_values}')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run env | grep JAX_ when import-time config errors appear","Pin and document accepted JAX_* values in CI configuration"],"tags":["jax","config","valueerror","environment-variable","enum"],"backgroundTag":"invalid-env-var-value","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}