{"record":{"id":"01ddd6d4747a1ed1","repo":"jax-ml/jax","slug":"brackets-should-contain-at-least-two-factors","errorCode":null,"errorMessage":"Brackets should contain at least two factors","messagePattern":"Brackets should contain at least two factors","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"jax/_src/custom_partitioning_sharding_rule.py","lineNumber":290,"sourceCode":"        batching_group = \"0\"\n\n      add_factor(f\"{BATCHING}{batching_group}\")\n      continue\n    if char in \"(), \":\n      if current_factor is not None:\n        add_factor(current_factor)\n        current_factor = None\n      if char == \"(\":\n        if current_compound_dim is not None:\n          raise ValueError(\n              \"Compound factors should be one level, nested brackets are not\"\n              \" allowed\")\n        current_compound_dim = []\n      elif char == \")\":\n        if current_compound_dim is None:\n          raise ValueError(\"Brackets are not balanced\")\n        if len(current_compound_dim) <= 1:\n          raise ValueError(\"Brackets should contain at least two factors\")\n        value.append(CompoundFactor(*current_compound_dim))\n        current_compound_dim = None\n      elif char == \",\":\n        all_values.append(ArrayMapping(*value))\n        value = []\n    elif char == \"_\" or char.isdigit() or char.isalpha():\n      if current_factor is None:\n        if str.isdigit(char):\n          raise ValueError(f\"Factor names have to start with a letter, but got '{char}'\")\n        current_factor = char\n      else:\n        current_factor += char\n    else:\n      raise ValueError(f\"Unknown character '{char}'\")\n\n  if current_compound_dim is not None:\n    raise ValueError(f\"Brackets are not balanced in rule: '{rule}'\")\n  if current_factor is not None:","sourceCodeStart":272,"sourceCodeEnd":308,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/custom_partitioning_sharding_rule.py#L272-L308","documentation":"A parenthesized compound factor must list at least two factors, e.g. '(a,b)'; '(a)' with a single factor is rejected because it adds no meaning.","triggerScenarios":"Rule like '(a),b->b' where a compound factor wraps one name.","commonSituations":"Programmatically wrapping factors in parentheses uniformly, including singletons; leftover parens after deleting a factor.","solutions":["Remove the parentheses around the single factor","Add a second factor if a compound dim was intended: '(a,b)'"],"exampleFix":"# before\nrule = '(a),b->b'\n# after\nrule = 'a,b->b'","handlingStrategy":"validation","validationCode":"import re\nassert not re.search(r'\\([^),]+\\)', rule), 'compound factor needs >= 2 factors'","typeGuard":"import re\ndef no_single_factor_parens(rule: str) -> bool:\n    return re.search(r'\\([^),]+\\)', rule) is None","tryCatchPattern":null,"preventionTips":["Never wrap a single factor in parentheses"],"tags":["jax","sharding","compound-factor","rule-syntax"],"backgroundTag":"invalid-dsl-syntax","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}