{"record":{"id":"d0e4211b018d9fb0","repo":"jax-ml/jax","slug":"invalid-value-default-env-for-jax-flag-name","errorCode":null,"errorMessage":"Invalid value \"{default_env}\" for JAX flag {name}","messagePattern":"Invalid value \"(.+?)\" for JAX flag (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"jax/_src/config.py","lineNumber":711,"sourceCode":"      option (and absl flag). It is converted to uppercase to define the\n      corresponding shell environment variable.\n    default: optional int, default value.\n    help: string, used to populate the flag help information as well as the\n      docstring of the returned context manager.\n\n  Returns:\n    A contextmanager to control the thread-local state value.\n  \"\"\"\n  if not isinstance(default, int):\n    raise TypeError(f\"Default value must be of type int, got {default} \"\n                    f\"of type {getattr(type(default), '__name__', type(default))}\")\n  name = name.lower()\n  default_env = os.getenv(name.upper())\n  if default_env is not None:\n    try:\n      default = int(default_env)\n    except ValueError:\n      raise ValueError(f\"Invalid value \\\"{default_env}\\\" for JAX flag {name}\")\n  config._contextmanager_flags.add(name)\n\n  def parser(new_val):\n    if new_val is not None and not isinstance(new_val, int):\n      raise ValueError(f'new int config value must be None or of type int, '\n                       f'got {new_val} of type {type(new_val)}')\n    if new_val is not None and validator is not None:\n      validator(new_val)\n    return new_val\n\n  s = State[int](name, default, help, update_global_hook,\n                 update_thread_local_hook, parser,\n                 include_in_jit_key=include_in_jit_key,\n                 include_in_trace_context=include_in_trace_context)\n  config.add_option(name, s, int, meta_args=[], meta_kwargs={\"help\": help})\n  setattr(Config, name, property(lambda _: s.value))\n  return s\n","sourceCodeStart":693,"sourceCodeEnd":729,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/config.py#L693-L729","documentation":"int_state reads the JAX_<FLAG> environment variable and calls int(default_env); if the string is not parseable as an integer, this ValueError is raised at jax import / flag definition.","triggerScenarios":"Exporting JAX_MY_FLAG=10_000, JAX_MY_FLAG=1e6, or JAX_MY_FLAG='' (empty string) — none parse via int().","commonSituations":"Shell scripts or CI setting numeric-looking env vars with commas, underscores, scientific notation, or accidentally empty values (e.g. `export JAX_MY_FLAG=$UNSET_VAR`).","solutions":["Use a plain integer string: export JAX_MY_FLAG=10000","Unset accidental empty values: unset JAX_MY_FLAG","Check for stray quotes/whitespace: echo \"[$JAX_MY_FLAG]\""],"exampleFix":"# before\nexport JAX_MY_FLAG=1e6\n# after\nexport JAX_MY_FLAG=1000000","handlingStrategy":"validation","validationCode":"raw = os.getenv('JAX_MY_FLAG')\nif raw is not None:\n    int(raw)  # fail fast with a clear message before importing jax","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Avoid underscores, commas, and scientific notation in JAX_* int env vars","Check for accidentally empty env vars (export X=$UNSET) in launch scripts"],"tags":["jax","config","valueerror","environment-variable","int"],"backgroundTag":"invalid-env-var-value","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}