{"record":{"id":"4f50d8ad32c14af2","repo":"jax-ml/jax","slug":"self-r-has-no-sharding","errorCode":null,"errorMessage":"{self!r} has no `sharding`.","messagePattern":"(.+?) has no `sharding`\\.","errorType":"exception","errorClass":"AttributeError","httpStatus":null,"severity":"error","filePath":"jax/_src/core.py","lineNumber":3129,"sourceCode":"  def __hash__(self):\n    return hash(self.inner_aval)\n\n  def str_short(self, short_dtypes=False, mesh_axis_types=False) -> str:\n    return f'AbstractFuture{{{self.inner_aval.str_short(True)}}}'\n\n  ndim = property(lambda self: len(self.shape))\n  size = property(lambda self: math.prod(self.shape))\n\n  @aval_method\n  def done(tracer):\n    return tracer.aval.done_fun(tracer)  # type: ignore\n\n  @property\n  def shape(self):\n    try:\n      return self.inner_aval.shape\n    except AttributeError:\n      raise AttributeError(f\"{self!r} has no `sharding`.\") from None\n\n  @property\n  def dtype(self):\n    try:\n      return self.inner_aval.dtype\n    except AttributeError:\n      raise AttributeError(f\"{self!r} has no `sharding`.\") from None\n\n  @property\n  def sharding(self):\n    try:\n      return self.inner_aval.sharding\n    except AttributeError:\n      raise AttributeError(f\"{self!r} has no `sharding`.\") from None\n\n  @property\n  def manual_axis_type(self):\n    try:","sourceCodeStart":3111,"sourceCodeEnd":3147,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/core.py#L3111-L3147","documentation":"A wrapper aval's .shape property delegates to inner_aval; when the inner aval has no shape (e.g. an abstract token or a ref of a non-shaped type), AttributeError is re-raised with a slightly misleading message saying the wrapper 'has no sharding'. It means the underlying value has no array shape at all.","triggerScenarios":"Calling .shape on an aval wrapping an abstract token or similar shapeless value, e.g. AbstractRef/AbstractToken accessed through generic aval code.","commonSituations":"Generic code (logging, assertions) calling .shape/.dtype on every operand including tokens/refs; custom primitives receiving token arguments.","solutions":["Skip shape access for token/ref avals (check a is abstract_token or hasattr(inner, 'shape'))","Restrict shape-touching code to ShapedArray instances","Guard with getattr(aval, 'shape', None)"],"exampleFix":"// before\nshapes = [a.shape for a in avals]  # crashes on tokens\n\n// after\nshapes = [a.shape for a in avals if hasattr(a.inner_aval, 'shape')]","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"def aval_has_shape(a):\n    return hasattr(getattr(a, 'inner_aval', a), 'shape')","tryCatchPattern":"try:\n    s = a.shape\nexcept AttributeError:\n    s = None  # token-like operand","preventionTips":["Filter tokens/refs before shape access in generic code","Use hasattr on inner_aval rather than catching blindly"],"tags":["jax","aval","attribute-error","tokens"],"backgroundTag":"attribute-missing-on-wrapper","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}