{"record":{"id":"6029af5c0762ca77","repo":"jax-ml/jax","slug":"the-symbolic-constraints-should-be-a-sequence-of-s","errorCode":null,"errorMessage":"The symbolic constraints should be a sequence of strings. Got {repr(constraints_str)}","messagePattern":"The symbolic constraints should be a sequence of strings\\. Got (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"jax/_src/export/shape_poly.py","lineNumber":1002,"sourceCode":"\n  All symbolic expressions that interact (e.g., appear in the argument shapes\n  for one JAX function invocation, or are involved in arithmetic operations)\n  must be from the same scope and must share the same SymbolicScope object.\n\n  Holds the constraints on symbolic expressions.\n\n  See [the README](https://docs.jax.dev/en/latest/export/shape_poly.html#user-specified-symbolic-constraints)\n  for more details.\n\n  Args:\n    constraints_str: A sequence of constraints on symbolic dimension expressions,\n      of the form `e1 >= e2` or `e1 <= e2` or `e1 == e2`.\n  \"\"\"\n\n  def __init__(self,\n               constraints_str: Sequence[str] = ()):\n    if isinstance(constraints_str, str):\n      raise ValueError(\n          \"The symbolic constraints should be a sequence of strings. \"\n          f\"Got {repr(constraints_str)}\")\n    self._initialized = False\n    self._location_frame = source_info_util.user_frame(\n        source_info_util.current().traceback)\n    # Keep the explicit constraints in the order in which they were added\n    self._explicit_constraints: list[_SymbolicConstraint] = []\n\n    # We cache the _DimExpr.bounds calls. The result depends only on the\n    # explicit and implicit constraints, so it is safe to keep it in the\n    # scope. Set the cache before we parse constraints. We also keep the\n    # bounds precision with which we computed the cached result.\n    self._bounds_cache: dict[_DimExpr,\n                             tuple[float, float, BoundsPrecision]] = {}\n\n    # We store here a decision procedure state initialized with all the\n    # _explicit_constraints.\n    self._decision_initial_state: Any | None = None","sourceCodeStart":984,"sourceCodeEnd":1020,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/export/shape_poly.py#L984-L1020","documentation":"SymbolicScope (created implicitly by polymorphic_shapes with constraints) expects a sequence of constraint strings like ('n >= 4',). Passing a single string would be iterated character-by-character, so JAX rejects it explicitly with this ValueError.","triggerScenarios":"Passing constraints='n>=4' (a bare string) instead of a tuple/list ['n>=4'] anywhere constraints are accepted (SymbolicScope(...), shapes with constraints, jax.export APIs).","commonSituations":"Copy-paste from docs where a tuple lost its parentheses; refactoring that turned a list into an optional string.","solutions":["Wrap the constraint(s) in a list or tuple: constraints=('n >= 4',) or ['a == b*2']","Check for accidental string concatenation producing a single str","Verify the parameter type at the call site before passing"],"exampleFix":"# before\nscope = jax.export.shape_poly.SymbolicScope('n >= 4')\n# after\nscope = jax.export.shape_poly.SymbolicScope(('n >= 4',))","handlingStrategy":"validation","validationCode":"assert not isinstance(constraints, str), 'pass a sequence of strings, e.g. (\"n >= 4\",)'","typeGuard":"def valid_constraints(c) -> bool:\n    return not isinstance(c, str) and all(isinstance(s, str) for s in c)","tryCatchPattern":"try:\n    scope = SymbolicScope(constraints)\nexcept ValueError as e:\n    if 'sequence of strings' in str(e): scope = SymbolicScope((constraints,))","preventionTips":["Always wrap constraint strings in a tuple/list literal with trailing comma","Lint call sites that accept sequences for accidental bare strings"],"tags":["jax","shape-polymorphism","constraints","api-misuse"],"backgroundTag":"sequence-argument-given-as-string","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}