{"record":{"id":"5d6f4328d14ce6b0","repo":"jax-ml/jax","slug":"array-type-must-have-a-shape-attribute-but-got","errorCode":null,"errorMessage":"Array type must have a `shape` attribute, but got {type(array_aval)}","messagePattern":"Array type must have a `shape` attribute, but got (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"jax/_src/pallas/core.py","lineNumber":592,"sourceCode":"      #     traceback_util.api_boundary(self.index_map, repro_user_func=True))\n      self.index_map = _IndexMapFunc(self.index_map)\n\n  def to_block_mapping(\n      self,\n      origin: OriginStr,\n      array_aval: jax_core.ShapedArray,\n      *,\n      # Inputs for the index_map\n      index_map_avals: Sequence[jax_core.AbstractValue],\n      index_map_tree: tree_util.PyTreeDef,\n      grid: GridMappingGrid,\n      vmapped_dims: tuple[int, ...],\n      debug: bool = False,\n      allow_captured_consts: bool = False,\n  ) -> BlockMapping:\n    if self.block_shape is not None:\n      if not hasattr(array_aval, \"shape\"):\n        raise ValueError(\n            \"Array type must have a `shape` attribute, but got\"\n            f\" {type(array_aval)}\"\n        )\n    if self.index_map is None:\n      index_map_func = default_index_map(len(array_aval.shape))\n      index_map_dbg = api_util.debug_info(\"pallas_call index_map\",\n                                          default_index_map, (),{}\n                                          )._replace(arg_names=(\"\",) * len(index_map_avals))\n      api_util.save_wrapped_fun_debug_info(index_map_func, index_map_dbg)\n    else:\n      index_map_func = self.index_map\n    if self.block_shape is None:\n      block_shape = _canonicalize_block_shape(array_aval.shape)\n    else:\n      block_shape = _canonicalize_block_shape(self.block_shape)\n      if len(array_aval.shape) != len(block_shape):\n        raise ValueError(\n            f\"Block shape for {origin} (= {block_shape}) \"","sourceCodeStart":574,"sourceCodeEnd":610,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/pallas/core.py#L574-L610","documentation":"BlockSpec.to_block_mapping needs the array's shape to build default index maps and block mappings. If block_shape is given but the input aval has no shape attribute (not an array aval — e.g. a token or a custom abstract value), it raises this error.","triggerScenarios":"Calling pallas_call with a BlockSpec having a non-None block_shape on an operand whose aval lacks .shape — e.g. donating a token, passing an odd object, or misordering out_shape and BlockSpec arguments.","commonSituations":"Mixing up positional arguments of pallas_call; using BlockSpecs with non-array outputs; internal state-discharge paths after API changes.","solutions":["Verify every operand/output paired with a BlockSpec is a real array (jnp.asarray-able)","Check argument order of pallas_call(f, out_shape, grid, in_specs, out_specs)","Pass block_shape=None for non-array operands if that is intended"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"assert hasattr(array_aval, 'shape'), f'operand aval {array_aval} is not an array'\n# only attach non-None block_shape BlockSpecs to array operands","typeGuard":"def is_array_aval(aval):\n    return hasattr(aval, 'shape') and hasattr(aval, 'dtype')","tryCatchPattern":null,"preventionTips":["Pair each BlockSpec with a concrete jnp array output","Double-check pallas_call positional argument order"],"tags":["jax","pallas","block-spec","aval"],"backgroundTag":"invalid-type-value","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}