{"record":{"id":"6f4ea337113385f3","repo":"jax-ml/jax","slug":"unknown-character-batching","errorCode":null,"errorMessage":"Unknown character '{BATCHING}'","messagePattern":"Unknown character '(.+?)'","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"jax/_src/custom_partitioning_sharding_rule.py","lineNumber":343,"sourceCode":"  Args:\n    rule: The Einsum notation like string for an operation.\n    reduction_factors: A tuple of factors that are reduction factors.\n    need_replication_factors: A tuple of factors that are need_replication factors.\n    permutation_factors: A tuple of factors that are permutation factors.\n    **factor_sizes: The optional factor sizes.\n\n  Raises:\n    ValueError: If there is any problem with the rule or factor_sizes.\n  \"\"\"\n  if not isinstance(rule, str):\n    raise TypeError(f\"rule must be a str, but got {type(rule)}\")\n  if not all(isinstance(size, int) for size in factor_sizes.values()):\n    raise TypeError(\n        f\"factor_sizes must be a dict of str to int, but got {factor_sizes}\")\n\n  # Replace ... with a single char to simplify parsing.\n  if BATCHING in rule:\n    raise ValueError(f\"Unknown character '{BATCHING}'\")\n  if \".\" in rule:\n    rule = rule.replace(\"...\", BATCHING)\n    if \".\" in rule:\n      raise ValueError(\"Character '.' must be used inside ellipsis '...'\")\n\n  try:\n    operands, results = rule.split(\"->\")\n  except ValueError as e:\n    raise ValueError(f\"There is no -> in rule: '{rule}'\") from e\n\n  operand_mappings = _parse_values(operands)\n  result_mappings = _parse_values(results)\n  return SdyShardingRule(operand_mappings, result_mappings,\n                         reduction_factors=reduction_factors,\n                         need_replication_factors=need_replication_factors,\n                         permutation_factors=permutation_factors,\n                         **factor_sizes)\n","sourceCodeStart":325,"sourceCodeEnd":361,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/custom_partitioning_sharding_rule.py#L325-L361","documentation":"The parser internally represents ellipsis with a sentinel character (BATCHING). A literal occurrence of that sentinel character already in the rule string would be ambiguous and is rejected up front.","triggerScenarios":"Only triggered if the rule string contains the internal BATCHING sentinel char (a reserved non-printable/punctuation char); ordinary users essentially never hit this unless constructing rules programmatically with exotic characters.","commonSituations":"Programmatically building rule strings that embed unusual characters; copying rules from serialized dumps that contain the sentinel.","solutions":["Remove the sentinel character from the rule; write ellipsis as '...'","If generating rules in code, restrict the alphabet to [A-Za-z0-9_(), ->.]"],"exampleFix":"# before\nrule = 'i\\x01,j->j'  # contains sentinel char\n# after\nrule = 'i,j->j'","handlingStrategy":"validation","validationCode":"import string\nassert set(rule) <= set(string.ascii_letters + string.digits + '(), ._->')","typeGuard":"def only_allowed_chars(rule: str) -> bool:\n    import string\n    return set(rule) <= set(string.ascii_letters + string.digits + '(), ._->')","tryCatchPattern":null,"preventionTips":["Never inject raw serialized/sentinel characters into rule strings"],"tags":["jax","sharding","reserved-character","rule-syntax"],"backgroundTag":"invalid-character-in-input","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}