{"record":{"id":"0bb95a7f8cb903e5","repo":"jax-ml/jax","slug":"unsupported-method-method","errorCode":null,"errorMessage":"Unsupported method: {method}","messagePattern":"Unsupported method: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"jax/_src/numpy/hijax.py","lineNumber":547,"sourceCode":"    return tuple(jnp.where(fill_mask, 0, entry) for entry in out)\n\n\ndef _searchsorted_impl(sorted_arr: ArrayLike, query: ArrayLike, *, dimension: int,\n                       batch_dims: int, side: str, dtype: np.dtype, method: str):\n  \"\"\"Main implementation of searchsorted primitive.\"\"\"\n  sorted_arr = jnp.moveaxis(sorted_arr, dimension, -1)\n  dtype = dtypes._maybe_canonicalize_explicit_dtype(dtype, \"searchsorted\")\n\n  if method == \"scan\":\n    impl: Callable[..., Array] = functools.partial(_searchsorted_scan_impl, unrolled=False)\n  elif method == \"scan_unrolled\":\n    impl = functools.partial(_searchsorted_scan_impl, unrolled=True)\n  elif method == \"compare_all\":\n    impl = _searchsorted_compare_all_impl\n  elif method == \"sort\":\n    impl = _searchsorted_sort_impl\n  else:\n    raise ValueError(f\"Unsupported method: {method}\")\n\n  fun = functools.partial(impl, side=side, dtype=dtype)\n  for _ in range(sorted_arr.ndim - batch_dims - 1):\n    fun = api.vmap(fun, in_axes=(0, None))\n  for _ in range(batch_dims):\n    fun = api.vmap(fun, in_axes=0)\n  return fun(sorted_arr, query)\n\n\n@api.jit(static_argnames=[\"side\", \"dtype\", \"unrolled\"])\ndef _searchsorted_scan_impl(\n    sorted_arr: Array, query: Array, side: str, dtype: np.dtype, unrolled: bool\n) -> Array:\n  \"\"\"Scan-based implementation of searchsorted.\"\"\"\n  assert sorted_arr.ndim == 1\n  assert side in [\"left\", \"right\"]\n  (n,) = sorted_arr.shape\n  if sorted_arr.size == 0:","sourceCodeStart":529,"sourceCodeEnd":565,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/numpy/hijax.py#L529-L565","documentation":"Raised inside _searchsorted_impl when the method string is none of 'scan', 'scan_unrolled', 'compare_all', 'sort'. This is a defensive check behind the SearchSorted primitive: normally the constructor (error 1402) already validated method, so seeing this means the impl was called directly (e.g. via expand or eval_shape) with an invalid method.","triggerScenarios":"Calling the private _searchsorted_impl with method='binary' or another typo'd name directly, or bypassing the primitive's constructor validation when re-creating it.","commonSituations":"Library code calling the private impl directly (functools.partial(_searchsorted_impl, method=...)) instead of going through the public primitive; stale method strings from an older API version.","solutions":["Route through the public searchsorted primitive so constructor validation catches bad methods with a clearer message","Use one of 'compare_all', 'scan', 'scan_unrolled', 'sort'"],"exampleFix":"# before\nfun = functools.partial(_searchsorted_impl, method='binary', ...)\n# after\nfun = functools.partial(_searchsorted_impl, method='scan', ...)\n# or better: use the public searchsorted API","handlingStrategy":"validation","validationCode":"assert method in ('compare_all', 'scan', 'scan_unrolled', 'sort'), method","typeGuard":"def valid_method(m: str) -> bool:\n    return m in ('compare_all', 'scan', 'scan_unrolled', 'sort')","tryCatchPattern":null,"preventionTips":["Don't call private _searchsorted_impl directly; use the public primitive","Centralize method-name constants instead of inline strings"],"tags":["jax","searchsorted","internal-api","argument-validation"],"backgroundTag":"invalid-enum-argument","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}